forked from iam-veeramalla/go-web-app-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsFile
42 lines (38 loc) · 1.27 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
41
42
pipeline {
agent any
environment {
DOCKER_IMAGE_TAG = "build-${env.BUILD_ID}" // Unique tag based on Jenkins build ID
}
stages {
stage('Build Docker Image') {
steps {
script {
// Build Docker image and push to DockerHub or another registry
docker.build("rajaram8888/go-web-app:${DOCKER_IMAGE_TAG}").push()
}
}
}
stage('Update Helm Chart') {
steps {
script {
// Update Helm chart's tag in values.yaml
sh "sed -i 's/tag: .*/tag: \"${DOCKER_IMAGE_TAG}\"/' helm/go-web-app-chart/values.yaml"
}
}
}
stage('Commit Changes') {
steps {
script {
// Commit the updated Helm chart back to GitHub
sh """
git config user.email "[email protected]"
git config user.name "Rajaram08950"
git add helm/go-web-app-chart/values.yaml
git commit -m "Update Helm chart tag to ${DOCKER_IMAGE_TAG}"
git push origin main
"""
}
}
}
}
}