Implemented auto commit new app version to GitOps by pipeline
This commit is contained in:
24
.jenkins/Jenkinsfile
vendored
24
.jenkins/Jenkinsfile
vendored
@ -45,5 +45,29 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Commit new version to GitOps repo') {
|
||||||
|
steps {
|
||||||
|
container('git') {
|
||||||
|
sh '''
|
||||||
|
git config --global user.name "jenkins[bot]"
|
||||||
|
git config --global user.email "jenkins@marcin00.pl"
|
||||||
|
'''
|
||||||
|
sh '''
|
||||||
|
# Podmień tag obrazu w pliku deploy.yaml
|
||||||
|
awk -v commit="$GIT_COMMIT" '
|
||||||
|
$0 ~ /name:[[:space:]]*api/ { in_api_container = 1; print; next }
|
||||||
|
in_api_container && $0 ~ /^[[:space:]]*image:[[:space:]]*/ {
|
||||||
|
sub(/:[^:[:space:]]+$/, ":" commit)
|
||||||
|
in_api_container = 0
|
||||||
|
print
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
' deploy.yaml > deploy.tmp && mv deploy.tmp deploy.yaml
|
||||||
|
'''
|
||||||
|
sh 'git commit -am "JENKINS: Changed deployed version to $GIT_COMMIT"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,14 @@ spec:
|
|||||||
- name: workspace-volume
|
- name: workspace-volume
|
||||||
mountPath: /home/jenkins/agent
|
mountPath: /home/jenkins/agent
|
||||||
|
|
||||||
|
- name: git
|
||||||
|
image: alpine/git:latest
|
||||||
|
tty: true
|
||||||
|
workingDir: /home/jenkins/agent
|
||||||
|
volumeMounts:
|
||||||
|
- name: workspace-volume
|
||||||
|
mountPath: /home/jenkins/agent
|
||||||
|
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/os: linux
|
kubernetes.io/os: linux
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user