-
Notifications
You must be signed in to change notification settings - Fork 22
/
Jenkinsfile
56 lines (45 loc) · 1.29 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
pipeline {
agent {
node {
label 'go'
}
}
parameters {
string(name:'TAG_NAME',defaultValue: 'latest',description:'')
}
environment {
IMAGE_NAME = 'kubespheredev/s2irun'
}
stages {
stage ('checkout scm') {
steps {
checkout(scm)
}
}
stage ('unit test'){
steps{
container ('go') {
sh '''
mkdir -p /home/jenkins/go/src/github.com/kubesphere
ln -s `pwd` /home/jenkins/go/src/github.com/kubesphere/s2irun
cd /home/jenkins/go/src/github.com/kubesphere/s2irun
make test'''
}
}
}
stage ('docker push') {
when{
branch 'master'
}
steps {
container ('go') {
sh "docker build . -t $IMAGE_NAME:$TAG_NAME"
withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "dockerhub-id" ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker push $IMAGE_NAME:$TAG_NAME'
}
}
}
}
}
}