forked from devopstrainingbanglore/gradle-web-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
48 lines (32 loc) · 1.39 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
node{
def gradle_Home = tool name: 'gradle-5.6', type: 'gradle'
def gradlecmd = "${gradle_Home}/bin/gradle"
//def GradleHome = tool name: 'gradle-5.6', type: 'gradle'
//def gradleCMD = "${GradleHome}/bin/gradle"
stage('gitcheckout'){
git credentialsId: '5e7cfcb2-a74a-485d-9e74-168e3683b0ea', url: 'https://github.com/mallanagouda4/gradle-web-app.git'
}
stage('gradlecleanbuild'){
//sh "${gradleCMD} clean build"
sh "${gradlecmd} clean build"
}
stage('dockerbuild'){
sh 'docker build -t ravikumara004/gradle-web-app .'
}
stage('imagepush'){
withCredentials([string(credentialsId: 'docker', variable: 'hub_pass')]) {
// some block
sh 'docker login -u ravikumara004 -p ${hub_pass}'
}
sh 'docker push ravikumara004/gradle-web-app'
}
stage('deployment'){
def dockerRun = 'docker run -d -p 8080:8080 --name gradle-web-app ravikumara004/gradle-web-app'
sshagent(['pemkey']) {
sh 'ssh -o StrictHostKeyChecking=no [email protected] docker stop gradle-web-app || true'
sh 'ssh [email protected] docker rm gradle-web-app || true'
sh 'ssh [email protected] docker rmi -f $(docker images -q) || true'
sh "ssh [email protected] ${dockerRun}"
}
}
}