-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
62 lines (54 loc) · 2.31 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
pipeline {
agent {
node {
label 'go'
}
}
environment {
REGISTRY = 'registry.cn-beijing.aliyuncs.com/pox'
APP_NAME = 'zkevm-sequencer-batch'
}
stages {
stage('check out from git') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: 'dev']],
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '', trackingSubmodules: true]],
userRemoteConfigs: [[credentialsId: 'gitaccount', url: 'http://git.everylink.ai/crosschain/sequencer']]])
}
}
stage('build & push') {
steps {
container('go') {
withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,credentialsId : 'dockerhub' ,usernameVariable : 'DOCKER_USERNAME' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker build -f Dockerfile -t $REGISTRY/$APP_NAME:SNAPSHOT-$BUILD_NUMBER .'
sh 'docker push $REGISTRY/$APP_NAME:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('deploy to sandbox') {
steps {
container ('go') {
withCredentials([
kubeconfigFile(
credentialsId: 'kubeconfig',
variable: 'KUBECONFIG')
]) {
sh 'envsubst < deploy/sandbox/node0/deployment.yaml | kubectl apply -f -'
sh 'envsubst < deploy/sandbox/node0/service.yaml | kubectl apply -f -'
sh 'envsubst < deploy/sandbox/node1/deployment.yaml | kubectl apply -f -'
sh 'envsubst < deploy/sandbox/node1/service.yaml | kubectl apply -f -'
sh 'envsubst < deploy/sandbox/node2/deployment.yaml | kubectl apply -f -'
sh 'envsubst < deploy/sandbox/node2/service.yaml | kubectl apply -f -'
}
}
}
}
}
}