forked from bcreddydevops/chinna-app
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathJenkinsfile
47 lines (43 loc) · 1.72 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
43
44
45
46
47
pipeline {
agent any
environment {
IMAGE_TAG = "${BUILD_NUMBER}"
}
stages {
stage('Docker Build') {
steps {
sh "docker build . -t sabair0509/hiring-app:$BUILD_NUMBER"
}
}
stage('Docker Push') {
steps {
withCredentials([string(credentialsId: 'docker-hub', variable: 'hubPwd')]) {
sh "docker login -u sabair0509 -p ${hubPwd}"
sh "docker push sabair0509/hiring-app:$BUILD_NUMBER"
}
}
}
stage('Checkout K8S manifest SCM'){
steps {
git branch: 'main', url: 'https://github.com/betawins/Hiring-app-argocd.git'
}
}
stage('Update K8S manifest & push to Repo'){
steps {
script{
withCredentials([usernamePassword(credentialsId: 'Github_server', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh '''
cat /var/lib/jenkins/workspace/$JOB_NAME/dev/deployment.yaml
sed -i "s/5/${BUILD_NUMBER}/g" /var/lib/jenkins/workspace/$JOB_NAME/dev/deployment.yaml
cat /var/lib/jenkins/workspace/$JOB_NAME/dev/deployment.yaml
git add .
git commit -m 'Updated the deploy yaml | Jenkins Pipeline'
git remote -v
git push https://$GIT_USERNAME:[email protected]/betawins/Hiring-app-argocd.git main
'''
}
}
}
}
}
}