-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
36 lines (30 loc) · 1.03 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
node('linux-python') {
container('python-imaging-buildkit') {
def rev
stage('checkout scm') {
rev = checkout(scm)
}
stage('Run pre-commit') {
runPreCommit()
}
stage('Build docker-image') {
dockerBuild()
}
stage('Publish image') {
withCredentials([usernamePassword(credentialsId: "dockerhub-digiratidlcs", usernameVariable: 'registryUsername', passwordVariable: 'registryPassword')]) {
dockerPush(registryUsername, registryPassword, rev.GIT_COMMIT)
}
}
}
}
def runPreCommit() {
sh "pre-commit run --all-files"
}
def dockerBuild() {
sh "docker build -t digirati/appetiser:latest ."
}
def dockerPush(def registryUsername, def registryPassword, def buildNumber) {
sh "docker login --username \"${registryUsername}\" --password \"${registryPassword}\""
sh "docker tag digirati/appetiser:latest digirati/appetiser:${buildNumber}"
sh "docker push digirati/appetiser:${buildNumber}"
}