-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_build.jenkins
42 lines (41 loc) · 1.23 KB
/
docker_build.jenkins
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
#!groovy
// Run docker build
properties([disableConcurrentBuilds()])
pipeline {
agent {
label 'master'
}
triggers { pollSCM('* * * * *') }
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
timestamps()
}
stages {
stage("docker login") {
steps {
echo " ============== docker login =================="
withCredentials([usernamePassword(credentialsId: 'dockerhub_semaev', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh """
docker login -u $USERNAME -p $PASSWORD
"""
}
}
}
stage("create docker image") {
steps {
echo " ============== start building image =================="
dir ('docker/toolbox') {
sh 'docker build -t semaev/toolbox:latest . '
}
}
}
stage("docker push") {
steps {
echo " ============== start pushing image =================="
sh '''
docker push semaev/toolbox:latest
'''
}
}
}
}