forked from zxcvbnmzsedr/let-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
40 lines (38 loc) · 1.26 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
pipeline {
agent any
stages {
stage('检出') {
steps {
checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]])
}
}
stage('构建') {
steps {
echo '构建中...'
sh 'mvn clean package'
echo '构建完成.'
archiveArtifacts(artifacts: 'let-search-web/target/let-search-web-1.0-SNAPSHOT.jar', fingerprint: true)
echo '上传到制品库'
}
}
stage('分发jar包') {
steps {
script {
echo '分发中...'
withCredentials([sshUserPrivateKey(credentialsId: '616f6277-6771-4763-8144-31cb536139c7', \
keyFileVariable: 'SSH_KEY_FOR_ABC', \
passphraseVariable: '', \
usernameVariable: '')]) {
sh "echo ${SSH_KEY_FOR_ABC}"
echo 'upload'
sh 'scp -i ${SSH_KEY_FOR_ABC} let-search-web/target/let-search-web-1.0-SNAPSHOT.jar [email protected]:/home/icsearch/java/'
echo '开始部署'
sh "ssh -i ${SSH_KEY_FOR_ABC} [email protected] 'systemctl restart let-search'"
echo '部署成功'
}
}
}
}
}
}