forked from camunda-community-hub/zeebe-hazelcast-exporter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
139 lines (125 loc) · 4.18 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
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-11
command: ["cat"]
tty: true
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 1
memory: 2Gi
'''
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timestamps()
timeout(time: 15, 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: '0.X.0', description: 'Which version to release?')
string(name: 'DEVELOPMENT_VERSION', defaultValue: '0.Y.0-SNAPSHOT', description: 'Next development version?')
}
stages {
stage('Prepare') {
steps {
container('maven') {
configFileProvider([configFile(fileId: 'maven-nexus-settings-zeebe', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn clean install -B -s $MAVEN_SETTINGS_XML -DskipTests'
}
}
}
}
stage('Build') {
when { not { expression { params.RELEASE } } }
steps {
container('maven') {
configFileProvider([configFile(fileId: 'maven-nexus-settings-zeebe', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn install -B -s $MAVEN_SETTINGS_XML'
}
}
}
post {
always {
junit testResults: "**/*/TEST-*.xml", keepLongStdio: true
}
}
}
stage('Upload') {
when { not { expression { params.RELEASE } } }
steps {
container('maven') {
configFileProvider([configFile(fileId: 'maven-nexus-settings-zeebe', variable: 'MAVEN_SETTINGS_XML')]) {
sh 'mvn -B -s $MAVEN_SETTINGS_XML generate-sources source:jar javadoc:jar deploy -DskipTests'
}
}
}
}
stage('Release') {
when { 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')
GITHUB_TOKEN = credentials('camunda-jenkins-github')
RELEASE_VERSION = "${params.RELEASE_VERSION}"
DEVELOPMENT_VERSION = "${params.DEVELOPMENT_VERSION}"
}
steps {
container('maven') {
configFileProvider([configFile(fileId: 'maven-nexus-settings-zeebe', variable: 'MAVEN_SETTINGS_XML')]) {
sshagent(['camunda-jenkins-github-ssh']) {
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 "ci@camunda.com"'
sh 'git config --global user.name "camunda-jenkins"'
sh 'mkdir ~/.ssh/ && ssh-keyscan github.com >> ~/.ssh/known_hosts'
sh 'mvn -B -s $MAVEN_SETTINGS_XML -DskipTests source:jar javadoc:jar release:prepare release:perform -Prelease'
sh '.ci/scripts/github-release.sh'
}
}
}
}
}
}
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).*/
}