forked from camunda-community-hub/zeeqs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
127 lines (113 loc) · 4.41 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
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'
yamlFile '.ci/podSpecs/distribution.yml'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timestamps()
timeout(time: 15, unit: 'MINUTES')
}
environment {
NEXUS = credentials("camunda-nexus")
DOCKER_HUB = credentials("camunda-dockerhub")
}
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 '.ci/scripts/distribution/prepare.sh'
sh 'mvn clean install -B -s $MAVEN_SETTINGS_XML -DskipTests'
}
}
container('docker') {
sh 'docker login --username ${DOCKER_HUB_USR} --password ${DOCKER_HUB_PSW}'
}
}
}
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}"
DOCKER_HUB = credentials("camunda-dockerhub")
}
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 "[email protected]"'
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'
}
}
}
container('maven') {
configFileProvider([configFile(fileId: 'maven-nexus-settings-zeebe', variable: 'MAVEN_SETTINGS_XML')]) {
sshagent(['camunda-jenkins-github-ssh']) {
sh 'mvn -pl app jib:build -Djib.to.tags=latest,${RELEASE_VERSION} -Djib.to.auth.username=${DOCKER_HUB_USR} -Djib.to.auth.password=${DOCKER_HUB_PSW} -P-jib-local,jib-multiplatform'
}
}
}
}
}
}
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).*/
}