Skip to content

Commit a469ea5

Browse files
committed
Pipeline rework
- Combine setup and build stage - Individual timeouts for build and release stages - Use milestones to prevent older builds from winning the release battle
1 parent 17aa9f4 commit a469ea5

1 file changed

Lines changed: 32 additions & 30 deletions

File tree

Jenkinsfile

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,27 @@
11
#!/usr/bin/env groovy
22

33
pipeline {
4-
5-
agent any
4+
agent none
65

76
tools {
87
jdk "jdk-17.0.1"
98
}
109

11-
options {
12-
// Sometimes builds freeze, but this doesn't have to be super aggressive.
13-
timeout(time: 30, unit: 'MINUTES')
14-
}
15-
16-
parameters {
17-
booleanParam(name: 'RELEASE', defaultValue: false, description: 'Publish artifacts without a build number.')
18-
}
19-
2010
stages {
11+
stage('Build') {
2112

22-
stage('Setup') {
13+
options {
14+
// Sometimes builds freeze, but this doesn't have to be super aggressive.
15+
timeout(time: 30, unit: 'MINUTES')
16+
}
2317

24-
steps {
18+
agent any
2519

26-
echo 'Setup Project'
20+
steps {
21+
echo 'Setup project.'
2722
sh 'chmod +x gradlew'
2823
sh './gradlew clean'
29-
}
30-
}
31-
32-
stage('Build') {
3324

34-
environment {
35-
RELEASE="${params.RELEASE}"
36-
}
37-
38-
steps {
3925
withCredentials([
4026
// build_secrets is parsed in SubprojectExtension#loadSecrets
4127
file(credentialsId: 'build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile'),
@@ -46,7 +32,7 @@ pipeline {
4632
}
4733

4834
post {
49-
success {
35+
always {
5036
archiveArtifacts artifacts: '**/build/libs/**/*.jar', fingerprint: true
5137

5238
withCredentials([
@@ -59,20 +45,36 @@ pipeline {
5945
}
6046
}
6147

62-
stage('Publish Concrete Version') {
63-
// Wait for user input and publish a release build.
48+
stage('Release') {
6449
when {
6550
expression {
66-
input message: 'Confirm'
67-
// if input is Aborted, the whole build will fail, otherwise
68-
// we must return true to continue
51+
input(message: 'Publish without build number?', ok: 'Yes', cancel: 'No')
52+
// If input is cancelled the entire step will abort. Return true so we continue on confirmation.
6953
return true
7054
}
7155
beforeAgent true
7256
}
7357

58+
options {
59+
// Sometimes builds freeze, but this doesn't have to be super aggressive.
60+
timeout(time: 30, unit: 'MINUTES')
61+
}
62+
63+
agent any
64+
65+
environment {
66+
RELEASE="true"
67+
}
68+
7469
steps {
75-
echo 'Test complete'
70+
// Prevent older builds from being released.
71+
milestone(label: 'Release Guardian')
72+
73+
echo 'Building for release.'
74+
echo '$RELEASE'
75+
echo './gradlew build publish --stacktrace --warn'
76+
77+
milestone(label: 'Release')
7678
}
7779
}
7880
}

0 commit comments

Comments
 (0)