-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
55 lines (55 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
48
49
50
51
52
53
54
55
pipeline {
options {
disableConcurrentBuilds()
}
agent {
kubernetes{
yaml """
apiVersion: v1
kind: Pod
metadata:
annotations:
linkerd.io/inject: enabled
spec:
serviceAccountName: jenkins-ecr
volumes:
- name: docker-config
configMap:
name: ecr-docker-config
containers:
- name: git
image: 343749756837.dkr.ecr.ap-southeast-1.amazonaws.com/git-kustomize:0.0.1
tty: true
command: ['cat']
- name: kaniko
image: gcr.io/kaniko-project/executor:v1.8.1-debug
tty: true
command: ['cat']
volumeMounts:
- name: docker-config
mountPath: /kaniko/.docker/
"""
}
}
stages {
stage('Build') {
when {
branch 'master'
}
steps {
container(name: 'kaniko') {
sh "/kaniko/executor --context `pwd` --destination 343749756837.dkr.ecr.ap-southeast-1.amazonaws.com/stable-asset-rewards/automation:${env.GIT_COMMIT.take(7)}"
}
container(name: 'git') {
withCredentials([file(credentialsId: 'jenkins-deployment-ssh', variable: 'SSH_KEYS')]) {
sh 'cp $SSH_KEYS /root/.ssh/id_ed25519 && chmod 0600 /root/.ssh/id_ed25519'
sh 'cd /tmp && git clone [email protected]:nutsfinance/k8s-manifests.git'
sh "cd /tmp/k8s-manifests/taiga-rewards-automation && kustomize edit set image 343749756837.dkr.ecr.ap-southeast-1.amazonaws.com/stable-asset-rewards/automation:${env.GIT_COMMIT.take(7)}"
sh 'git config --global user.email "[email protected]" && git config --global user.name "CI Deployment"'
sh "cd /tmp/k8s-manifests/ && git commit -am 'updating stable-asset-rewards/automation to ${env.GIT_COMMIT.take(7)}' && git push"
}
}
}
}
}
}