This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
forked from atomix/atomix
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
141 lines (128 loc) · 3.93 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
def buildName = "${env.JOB_BASE_NAME.replaceAll("%2F", "-").replaceAll("\\.", "-").take(20)}-${env.BUILD_ID}"
pipeline {
agent {
kubernetes {
cloud 'zeebe-ci'
label "zeebe-ci-build_${buildName}"
defaultContainer 'jnlp'
yaml '''\
apiVersion: v1
kind: Pod
metadata:
labels:
agent: zeebe-ci-build
spec:
nodeSelector:
cloud.google.com/gke-nodepool: agents-n1-standard-32-netssd-preempt
tolerations:
- key: "agents-n1-standard-32-netssd-preempt"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: maven
image: maven:3.6.0-jdk-8
command: ["cat"]
tty: true
env:
- name: JAVA_TOOL_OPTIONS
value: |
-XX:+UseContainerSupport
resources:
limits:
cpu: 4
memory: 8Gi
requests:
cpu: 4
memory: 8Gi
'''
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timestamps()
timeout(time: 45, unit: 'MINUTES')
}
environment {
NEXUS = credentials("camunda-nexus")
}
parameters {
booleanParam(name: 'RELEASE', defaultValue: false, description: 'Build a release from current commit?')
string(name: 'RELEASE_VERSION', defaultValue: '3.2.0-alpha1', description: 'Which version to release?')
string(name: 'DEVELOPMENT_VERSION', defaultValue: '3.2.0-SNAPSHOT', description: 'Next development version?')
}
stages {
stage('Prepare') {
steps {
container('maven') {
sh 'mvn clean install -B -s settings.xml -DskipTests -Dmaven.test.skip -Dmaven.javadoc.skip -Ddockerfile.skip'
}
}
}
stage('Build') {
when { not { expression { params.RELEASE } } }
steps {
container('maven') {
sh 'mvn install -B -s settings.xml -Ddockerfile.skip -Dmaven.test.redirectTestOutputToFile -Dsurefire.rerunFailingTestsCount=3'
}
}
post {
always {
junit testResults: "**/*/TEST-*.xml", keepLongStdio: true
}
}
}
stage('Upload') {
when {
allOf {
branch 'develop'; not { expression { params.RELEASE } }
}
}
steps {
container('maven') {
sh 'mvn -B -s settings.xml generate-sources source:jar javadoc:jar deploy -DskipTests -Ddockerfile.skip'
}
}
}
stage('Release') {
when {
allOf {
branch 'develop'; expression { params.RELEASE }
}
}
environment {
MAVEN_CENTRAL = credentials('maven_central_deployment_credentials')
GPG_PASS = credentials('password_maven_central_gpg_signing_key')
GPG_PUB_KEY = credentials('maven_central_gpg_signing_key_pub')
GPG_SEC_KEY = credentials('maven_central_gpg_signing_key_sec')
RELEASE_VERSION = "${params.RELEASE_VERSION}"
DEVELOPMENT_VERSION = "${params.DEVELOPMENT_VERSION}"
}
steps {
container('maven') {
sshagent(['camunda-jenkins-github-ssh']) {
sh 'export GPG_TTY=$(tty)'
sh 'gpg -q --import ${GPG_PUB_KEY} '
sh 'gpg -q --allow-secret-key-import --import --no-tty --batch --yes ${GPG_SEC_KEY}'
sh 'git config --global user.email "[email protected]"'
sh 'git config --global user.name "camunda-jenkins"'
sh 'mkdir ~/.ssh/ && ssh-keyscan github.com >> ~/.ssh/known_hosts'
sh 'mvn -B -s settings.xml -DskipTests source:jar javadoc:jar release:prepare release:perform'
}
}
}
}
}
post {
always {
// Retrigger the build if the node disconnected
script {
if (nodeDisconnected()) {
build job: currentBuild.projectName, propagate: false, quietPeriod: 60, wait: false
}
}
}
}
}
boolean nodeDisconnected() {
return currentBuild.rawBuild.getLog(500).join('') ==~ /.*(ChannelClosedException|KubernetesClientException|ClosedChannelException).*/
}