-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
95 lines (76 loc) · 2.82 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
pipeline {
agent {
label "linuxbuildnode"
}
stages {
stage('SCM') {
steps {
git 'https://github.com/Kira-0007/jenkins-docker-maven-java-webapp.git'
}
}
stage('Build by Maven Package') {
steps {
sh 'mvn clean package'
}
}
stage('Build Docker OWN image') {
steps {
sh "sudo docker build -t bunny001/javaweb:${BUILD_TAG} ."
}
}
stage('Push Image to Dcoker Hub') {
steps {
withCredentials([string(credentialsId: 'DOCKER_HUB_PWD', variable: 'DOCKER_HUB_PASS_CODE')]) {
// some block
sh "sudo docker login -u bunny001 -p $DOCKER_HUB_PASS_CODE"
}
sh "sudo docker push bunny001/javaweb:${BUILD_TAG}"
}
}
stage('Deploy webAPP in DEV Env') {
steps {
sh 'sudo docker rm -f myjavaapp'
sh "sudo docker run -d -p 8080:8080 --name myjavaapp bunny001/javaweb:${BUILD_TAG}"
}
}
stage('Deploy webAPP in QA/TestEnv') {
steps {
sshagent(['QA_ENV_SSH_CRED']) {
// some block
sh "ssh -o StrictHostKeyChecking=no [email protected] sudo docker rm -f myjavaapp"
sh "ssh [email protected] sudo docker run -d -p 8080:8080 --name myjavaapp bunny001/javaweb:${BUILD_TAG}"
}
}
}
/*
stage('QAT Test') {
steps {
sh 'curl --silent http://52.66.20.45:8080/java-web-app/ | grep India'
}
}
*/
stage('approval') {
steps {
script {
Boolean userInput = input(id: 'Proceed1', message: 'Promote build?', parameters: [[$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']])
echo 'userInput: ' + userInput
if(userInput == true) {
// do action
} else {
// not do action
echo "Action was aborted."
}
}
}
}
stage('Deploy webAPP in Prod Env') {
steps {
sshagent(['QA_ENV_SSH_CRED']) {
// some block
sh "ssh -o StrictHostKeyChecking=no [email protected] sudo docker rm -f myjavaapp"
sh "ssh [email protected] sudo docker run -it -d -p 8080:8080 --name myjavaapp bunny001/javaweb:${BUILD_TAG}"
}
}
}
}
}