-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkinsfile
47 lines (47 loc) · 2.46 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
podTemplate(containers: [containerTemplate(name: 'maven', image: 'bensonre/jenkins-slave', ttyEnabled: true, command: 'cat')], volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]) {
node(POD_LABEL) {
try{
stage('Get a Maven project') {
git 'https://github.com/200803-java-devops/Jank8-sSampleWebProject2'
container('maven') {
stage('Test') {
sh 'mvn test'
}
}
slackSend(color: '#BDFFC3', message: 'Testing stage for Jank8s-Sample App 2 Succeeded')
}
}catch(e){
slackSend(color: '#FF0000', message: 'Testing stage for Jank8s-Sample App 2 Failed. Check console output at http://ec2-35-166-28-86.us-west-2.compute.amazonaws.com:30000/job/gittest_sample2/ to view the results.')
error "${e}"
}
}
}
podTemplate(containers: [containerTemplate(name: 'maven', image: 'bensonre/jenkins-slave', ttyEnabled: true, command: 'cat')], volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]) {
node(POD_LABEL) {
try{
stage('Get a Maven project') {
git 'https://github.com/200803-java-devops/Jank8-sSampleWebProject2'
container('maven') {
stage('Build a Maven project') {
sh 'mvn clean package -DskipTests'
sh 'cat src/main/Static/index.html'
}
stage('docker'){
sh 'docker build -t jank8s/jenkins-sample2 .'
withCredentials([usernamePassword(credentialsId: 'docker_hub_credentials', passwordVariable: 'token', usernameVariable: 'username')]) {
sh 'docker login -u '+ username+' -p '+token
sh 'docker push jank8s/jenkins-sample2'
}
}
stage('delivery'){
sh 'curl http://ec2-35-166-28-86.us-west-2.compute.amazonaws.com:30006/sample2'
}
}
slackSend(color: '#BDFFC3', message: 'Build and Deployment stages for Jank8s-Sample App 2 Succeeded')
}
}catch(e){
slackSend(color: '#FF0000', message: 'Build and Deployment stages for Jank8s-Sample App 2 Failed. Check console output at http://ec2-35-166-28-86.us-west-2.compute.amazonaws.com:30000/job/gittest_sample2/ to view the results.')
error "${e}"
}
}
}