-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
49 lines (45 loc) · 1.31 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
def gitVersion() {
desc = sh(script: "git describe --tags --long --dirty", returnStdout: true)?.trim()
parts = desc.split('-')
assert parts.size() in [3, 4]
dirty = (parts.size() == 4)
tag = parts[0]
count = parts[1]
sha = parts[2]
if (count == '0' && !dirty) {
return tag
}
return sprintf( '%1$s.dev%2$s+%3$s', [tag, count, sha.substring(1)])
}
def isTag() {
commit = getCommit()
if (commit) {
desc = sh(script: "git describe --tags --long ${commit}", returnStdout: true)?.trim()
match = desc =~ /.+-[0-9]+-g[0-9A-Fa-f]{6,}$/
result = !match
match = null
return result
}
return false
}
node('docker') {
stages {
stage('Checkout') {
checkout scm
}
stage('Build Image') {
withCredentials([
usernamePassword(credentialsId: 'docker public',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD')]) {
def builtImage = docker.build("${USERNAME}/docker-alpine-oracle-jdk-arm")
}
}
stage('Push Image') {
when { tag "release-*" }
docker.withRegistry('https://hub.docker.com/','docker public') {
builtImage.push()
}
}
}
}