-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-CD
43 lines (40 loc) · 1.27 KB
/
Jenkinsfile-CD
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
pipeline{
agent any
environment {
APP_NAME = "auth-service"
}
stages {
stage ('Clean workspace') {
steps {
cleanWs()
}
}
stage("Checkout from SCM"){
steps {
git branch: 'master', credentialsId: 'GitHub', url: 'https://github.com/Kien-fit/gitops-cicd'
}
}
stage("Update the deployment tag"){
steps {
sh """
cat auth.yml
sed -i'' -e 's/${APP_NAME}:.*/${APP_NAME}:${IMAGE_TAG}/g' auth.yml
cat auth.yml
"""
}
}
stage("Push the changed deployment file to git"){
steps {
sh """
git config --global user.name 'Kien-fit'
git config --global user.email '[email protected]'
git add auth.yml
git commit -m 'Update deployment image tag ${APP_NAME}:${IMAGE_TAG}'
"""
withCredentials([gitUsernamePassword(credentialsId: 'GitHub', gitToolName: 'Default')]) {
sh 'git push https://github.com/Kien-fit/gitops-cicd master'
}
}
}
}
}