-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
172 lines (169 loc) · 5.26 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
pipeline {
agent none
triggers {
cron('@daily')
}
stages {
stage('Build the Docker image') {
agent {
dockerfile true
}
steps {
echo "building image from Dockerfile"
sh 'echo JENKINS_HOME = $JENKINS_HOME'
}
}
stage('Build Java app') {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
steps {
echo "cleaning and packaging java app"
sh 'mvn -B -DskipTests clean package'
}
}
stage('Build Python app') {
agent {
docker {
image 'python:2-alpine'
}
}
steps {
echo "compiling all python source files"
sh 'python -m py_compile jenkins/pysrc/*.py'
}
}
stage('Test Java app') {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
steps {
sh 'mvn test'
stash includes: '**/target/', name: 'app'
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Test Python app') {
agent {
docker {
image 'qnib/pytest'
}
}
steps {
// sh 'pip install --upgrade pip && pip install selenium'
// sh 'py.test --verbose --junit-xml test-reports/results.xml jenkins/pysrc/JenkinsDemoLoginTest.py'
sh 'py.test --verbose --junit-xml test-reports/results.xml jenkins/pysrc/JokeOfTheDayTest.py'
sh 'py.test --verbose --junit-xml test-reports/results.xml jenkins/pysrc/my_words_distance.py'
}
post {
always {
junit 'test-reports/results.xml'
}
}
}
stage('Publish for dev') {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/:/root/'
}
}
when {
branch 'dev'
}
steps {
// sh 'npm install'
unstash 'app'
// sh './my-mvn-sonar-run.sh'
echo 'You may see all issues at https://sonarcloud.io/projects'
// input message: 'Finished using the web site? (Click "Proceed" to continue)'
}
}
stage('Review prod environment') {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
when {
branch 'prod'
}
steps {
// sh 'npm install'
sh 'printenv'
input message: 'Approve Prod Environment? \n (Click "Proceed" to continue)'
}
}
stage('Deliver') {
parallel {
stage('Deliver On Linux') {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
steps {
unstash 'app'
echo "localy installing and running the java app"
sh './scripts/deliver.sh'
}
}
stage('Deliver On Windows') {
// agent {
// label "windows"
// }
steps {
echo "Template for parallel Delivery on Windows platform"
// bat "./scripts/deliver.bat"
}
}
}
}
stage('Deploy') {
parallel {
stage('Deploy Maven pkg') {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
steps {
unstash 'app'
echo "Deploying maven pkg"
// sh './scripts/mvn-deploy.sh vsilverman'
}
}
stage('Deploy docker pkg') {
agent any
steps {
echo "Deploying docker pkg"
sh './scripts/dkr-deploy.sh vsilverman jenkinsci/blueocean jenbo latest'
}
}
}
}
stage('Demo') {
when {
expression {
currentBuild.result == null || currentBuild.result == 'SUCCESS'
}
}
steps {
echo "Build ${env.BUILD_ID} on ${env.JENKINS_URL} is ready for Demo"
}
}
}
}