forked from betawins/hiring-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
51 lines (47 loc) · 1.78 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
48
49
50
51
pipeline {
agent any
environment {
IMAGE_TAG = "${BUILD_NUMBER}"
}
stages {
stage('Docker Build') {
steps {
sh "docker build . -t rajashekhar36/new-argo-image:$IMAGE_TAG"
}
}
stage('Docker Push') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker-hub', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'hubPwd')]) {
sh '''
echo "${hubPwd}" | docker login -u ${DOCKER_USERNAME} --password-stdin
'''
sh "docker push rajashekhar36/new-argo-image:${IMAGE_TAG}"
}
}
}
stage('Checkout K8S manifest SCM'){
steps {
git credentialsId: 'github-credentials',
url: 'https://github.com/Reddylab36/Hiring-app-argocd.git',
branch: 'main'
}
}
stage('Update K8S manifest & push to Repo'){
steps {
script{
withCredentials([usernamePassword(credentialsId: 'github-credentials', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh '''
cat deployment.yaml
sed -i "s/5/${BUILD_NUMBER}/g" deployment.yaml
cat deployment.yaml
git add .
git commit -m 'Updated the deploy yaml | Jenkins Pipeline'
git remote -v
git push https://github.com/Reddylab36/Hiring-app-argocd.git HEAD:main
'''
}
}
}
}
}
}