forked from jenkinsci/docker-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
106 lines (99 loc) · 4.21 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
pipeline {
agent none
options {
buildDiscarder(logRotator(daysToKeepStr: '10'))
timestamps()
}
triggers {
pollSCM('H * * * *')
}
stages {
stage('Build') {
parallel {
stage('Windows') {
agent {
label "windock"
}
options {
timeout(time: 60, unit: 'MINUTES')
}
environment {
DOCKERHUB_ORGANISATION = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}"
}
steps {
powershell '& ./build.ps1 test'
script {
def branchName = "${env.BRANCH_NAME}"
if (branchName ==~ 'master') {
// publish the images to Dockerhub
infra.withDockerCredentials {
powershell '& ./build.ps1 publish'
}
}
if(env.TAG_NAME != null) {
def tagItems = env.TAG_NAME.split('-')
if(tagItems.length == 2) {
def remotingVersion = tagItems[0]
def buildNumber = tagItems[1]
// we need to build and publish the tag version
infra.withDockerCredentials {
powershell "& ./build.ps1 -PushVersions -RemotingVersion $remotingVersion -BuildNumber $buildNumber -DisableEnvProps publish"
}
}
}
}
// cleanup any docker images
powershell '& docker system prune --force --all'
}
post {
always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml')
}
}
}
stage('Linux') {
agent {
label "docker&&linux"
}
options {
timeout(time: 30, unit: 'MINUTES')
}
environment {
DOCKERHUB_ORGANISATION = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}"
}
steps {
sh './build.sh'
script {
def branchName = "${env.BRANCH_NAME}"
if (branchName ==~ 'master') {
// publish the images to Dockerhub
infra.withDockerCredentials {
sh './build.sh publish'
}
}
if(env.TAG_NAME != null) {
def tagItems = env.TAG_NAME.split('-')
if(tagItems.length == 2) {
def remotingVersion = tagItems[0]
def buildNumber = tagItems[1]
// we need to build and publish the tag version
infra.withDockerCredentials {
sh "./build.sh -p -r $remotingVersion -b $buildNumber -d publish"
}
}
}
}
// cleanup any docker images
sh 'docker system prune --force --all'
}
post {
always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/*.xml')
}
}
}
}
}
}
}
// vim: ft=groovy