-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
44 lines (44 loc) · 1.41 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
pipeline {
agent any
environment {
TARGET_HOST = "[email protected]"
}
stages {
stage('Checkout') {
steps {
git branch: 'master',
credentialsId: 'github_access_token',
url : 'https://github.com/leeworld9/Test_Jenkins.git'
}
}
stage('build') {
steps {
sh "chmod +x ./gradlew"
sh "./gradlew clean"
sh "./gradlew build"
sh "docker build -t leeworld9/backend ."
}
}
stage('pushing to dockerhub') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker_hub', usernameVariable: 'docker_user', passwordVariable: 'docker_pwd')]) {
sh "docker login -u ${docker_user} -p ${docker_pwd}"
}
sh "docker push leeworld9/backend"
}
}
stage('deploy') {
steps {
sshagent (credentials: ['matching_backend_ssh']) {
sh """
ssh -o StrictHostKeyChecking=no ${TARGET_HOST} '
hostname
docker pull leeworld9/backend
docker run -d -p 8080:8080 -it leeworld9/backend:latest
'
"""
}
}
}
}
}