-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
66 lines (57 loc) · 1.61 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
def remote = [:]
remote.name = 'sago_web_server'
remote.host = '101.101.161.9'
remote.port = 8080
remote.allowAnyHosts = true
pipeline {
agent any
environment {
app = ''
}
stages {
stage('Build') {
steps {
sh './gradlew clean build -x test'
archiveArtifacts 'build/libs/*.jar'
}
}
stage('Unit Test') {
steps {
sh './gradlew test'
}
}
stage('Integration Test') {
steps {
sh './gradlew integrationTest'
}
}
stage('Docker build image') {
steps {
script {
app = docker.build('luok377/sago', '.')
}
}
}
stage('Docker push image') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'docker-account') {
app.push('latest')
}
}
}
}
stage("Deploy") {
steps{
script {
withCredentials([usernamePassword(credentialsId: 'ssh_key', passwordVariable: 'password', usernameVariable: 'userName')]) {
remote.user = userName
remote.password = password
sshCommand remote: remote, command: 'cd /sago_docker_container'
sshCommand remote: remote, command: 'docker pull luok377/sago'
}
}
}
}
}
}