-
Notifications
You must be signed in to change notification settings - Fork 1
/
jenkinsfileOnPre
66 lines (51 loc) · 1.54 KB
/
jenkinsfileOnPre
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
pipeline {
agent {
node {
label 'base'
}
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
KUBECONFIG_CREDENTIAL_ID = 'admin'
REGISTRY = 'docker.io'
DOCKERHUB_NAMESPACE = 'comingweb3'
APP_NAME = 'sherpax-wallet-v2-pre'
}
parameters {
string(name: 'BRANCH_NAME', defaultValue: 'pre', description: '')
}
stages {
stage('拉取代码') {
steps {
git(branch: 'pre', url: 'https://github.com/chainx-org/sherpax-wallet-v2.git', credentialsId: 'github-id', changelog: true, poll: false)
}
}
stage('推送镜像') {
steps {
container('base') {
withCredentials([usernamePassword(credentialsId : "$DOCKER_CREDENTIAL_ID" ,passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker build --network host -f Dockerfile.dev -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER .'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER'
}
}
}
}
stage('部署') {
steps {
container('base') {
script {
withCredentials([
kubeconfigFile(
credentialsId: 'admin',
variable: 'KUBECONFIG')
])
{
sh 'envsubst < deploy/pre/deploy-sherpax-wallet-v2.yaml | kubectl apply -f -'
}
}
}
}
}
}
}