-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJenkinsfile
41 lines (37 loc) · 1.28 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
pipeline {
agent any
stages {
stage('Clone') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [],
userRemoteConfigs: [[url: 'https://github.com/kubesphere-sigs/demo-go-http']]])
}
}
stage('Build') {
steps {
// generate the image tag name
script {
env.TAGNAME=sh returnStdout: true, script: 'git rev-parse --short HEAD'
}
container('base') {
sh '''
echo $TAGNAME
docker build . -t docker.io/surenpi/test:$TAGNAME
'''
}
}
}
stage('Push Image') {
steps {
container('base') {
withCredentials([usernamePassword(credentialsId : 'dockerhub' ,passwordVariable : 'PASS' ,usernameVariable : 'USER' ,)]) {
sh '''
docker login -u$USER -p$PASS docker.io
docker push docker.io/surenpi/test:$TAGNAME
'''
}
}
}
}
}
}