-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (70 loc) · 1.79 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
pipeline {
agent {
kubernetes {
label 'jenkins-slave'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: dind
image: docker:18.09-dind
securityContext:
privileged: true
- name: docker
env:
- name: DOCKER_HOST
value: 127.0.0.1
image: docker:18.09
command:
- cat
tty: true
- name: tools
image: argoproj/argo-cd-ci-builder:v1.0.0
command:
- cat
tty: true
"""
}
}
stages {
stage('Build') {
environment {
DOCKERHUB_CREDS = credentials('dockerhub')
}
steps {
container('docker') {
sh "until docker ps; do sleep 3; done && docker build -t rayleshh/argocd-app:${env.GIT_COMMIT} ."
sh "echo '${DOCKERHUB_CREDS_PSW}' | docker login -u '${DOCKERHUB_CREDS_USR}' --password-stdin"
sh "docker push rayleshh/argocd-app:${env.GIT_COMMIT}"
}
}
}
stage('Deploy E2E') {
environment {
GIT_CREDS = credentials('dockerhub')
}
steps {
container('tools') {
sh 'git clone https://${GIT_CREDS_USR}:"${GIT_CREDS_PSW}"@github.com/rayleshh/gitops-infra.git'
sh "git config --global user.email '[email protected]'"
dir("gitops-infra") {
sh "cd ./e2e && kustomize edit set image rayleshh/argocd-app:${env.GIT_COMMIT}"
sh "git commit -am 'Publish new version' && git push || echo 'no changes'"
}
}
}
}
stage('Deploy to Prod') {
steps {
container('tools') {
dir("gitops-infra") {
sh "cd ./prod && kustomize edit set image rayleshh/argocd-app:${env.GIT_COMMIT}"
sh "git commit -am 'Publish new version' && git push || echo 'no changes'"
}
}
}
}
}
}