Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
76 lines (71 loc) · 2.09 KB
/
Copy pathJenkinsfile
File metadata and controls
76 lines (71 loc) · 2.09 KB
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
// (5)
def ssh_publisher(SERVER_CONFIG) {
sshPublisher(
continueOnError: false,
failOnError: true,
publishers:[
sshPublisherDesc(
configName: "${SERVER_CONFIG}",
verbose: true,
transfers: [
// (5.1) Copy script files
sshTransfer(
sourceFiles: "deploy/develop/script/*.sh",
removePrefix: "deploy/develop/script",
remoteDirectory: "build/script"
),
// (5.2) Copy build files
sshTransfer(
sourceFiles: "build/libs/*.jar",
removePrefix: "build/libs",
remoteDirectory: "/build/lib",
// Absolute path.
execCommand: "sh /home/ubuntu/build/script/deploy_server.sh"
),
// (5.3) Health check
sshTransfer(
// Absolute path.
execCommand: "sh /home/ubuntu/build/script/health_check.sh"
)
]
)
]
)
}
// (1)
pipeline {
environment {
// (2) Registered in Jenkins
SERVER_LIST = "NaviForYou"
}
agent any
stages {
stage('Add Env') {
steps {
withCredentials([file(credentialsId: 'application', variable: 'application')]) {
sh 'cp ${application} src/main/resources/application.yml'
}
}
}
stage("Build") {
// (3)
steps {
sh "chmod +x gradlew"
sh "./gradlew clean build -x test"
}
}
stage("Deploy") {
steps {
echo "deploy.."
echo "${SERVER_LIST}"
script {
// (4)
SERVER_LIST.tokenize(',').each {
echo "SERVER: ${it}"
ssh_publisher("${it}")
}
}
}
}
}
}