-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
28 lines (27 loc) · 1.52 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
pipeline {
agent any
stages {
stage('Pull Code') {
steps {
git branch: 'main', credentialsId: 'gitlab_auth', url: 'http://192.168.246.152:8081/devops/blog.git'
}
}
stage('Build And Push Docker Image') {
steps {
sh 'docker build -t go-blog:1.1 .'
withCredentials([usernamePassword(credentialsId: 'harbor_auth', passwordVariable: 'password', usernameVariable: 'username')]) {
sh 'docker login --username=$username --password=$password 192.168.246.152'
sh 'docker tag go-blog:1.1 192.168.246.152/blog/go-blog:1.1'
sh 'docker push 192.168.246.152/blog/go-blog:1.1'
}
}
}
stage('Deploy Remote Server') {
steps {
withCredentials([usernamePassword(credentialsId: 'harbor_auth', passwordVariable: 'password', usernameVariable: 'username')]) {
sshPublisher(publishers: [sshPublisherDesc(configName: 'deploy_server', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'sh ./script/deploy.sh $password', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: 'script', remoteDirectorySDF: false, removePrefix: '', sourceFiles: 'deploy.sh')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
}
}
}
}
}