Skip to content

Commit 028d068

Browse files
authored
Merge pull request #33 from marko-bekhta/build/split-build-release-jobs
Split build/release jobs
2 parents 33dfc69 + f3dd3c1 commit 028d068

File tree

3 files changed

+114
-74
lines changed

3 files changed

+114
-74
lines changed

Jenkinsfile

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@Library('hibernate-jenkins-pipeline-helpers@1.5') _
1+
@Library('hibernate-jenkins-pipeline-helpers@1.17') _
22

33
import org.hibernate.jenkins.pipeline.helpers.version.Version
44

@@ -14,25 +14,6 @@ pipeline {
1414
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
1515
disableConcurrentBuilds(abortPrevious: false)
1616
}
17-
parameters {
18-
string(
19-
name: 'RELEASE_VERSION',
20-
defaultValue: '',
21-
description: 'The version to be released, e.g. 1.0.0.Final.',
22-
trim: true
23-
)
24-
string(
25-
name: 'DEVELOPMENT_VERSION',
26-
defaultValue: '',
27-
description: 'The next version to be used after the release, e.g. 1.0.1-SNAPSHOT.',
28-
trim: true
29-
)
30-
booleanParam(
31-
name: 'RELEASE_DRY_RUN',
32-
defaultValue: false,
33-
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts.'
34-
)
35-
}
3617
stages {
3718
stage('Build') {
3819
steps {
@@ -41,47 +22,5 @@ pipeline {
4122
}
4223
}
4324
}
44-
stage('Release') {
45-
when {
46-
beforeAgent true
47-
// Releases must be triggered explicitly with parameters
48-
expression { return params.RELEASE_VERSION }
49-
}
50-
steps {
51-
script {
52-
// Check that all the necessary parameters are set
53-
if (!params.RELEASE_VERSION) {
54-
throw new IllegalArgumentException("Missing value for parameter RELEASE_VERSION.")
55-
}
56-
if (!params.DEVELOPMENT_VERSION) {
57-
throw new IllegalArgumentException("Missing value for parameter DEVELOPMENT_VERSION.")
58-
}
59-
60-
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
61-
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
62-
echo "Performing full release for version ${releaseVersion.toString()}"
63-
64-
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
65-
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
66-
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
67-
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
68-
sshagent(['ed25519.Hibernate-CI.github.com']) {
69-
sh 'cat $HOME/.ssh/config'
70-
sh """ \
71-
./mvnw release:prepare \
72-
-Dtag=${releaseVersion.toString()} \
73-
-DreleaseVersion=${releaseVersion.toString()} \
74-
-DdevelopmentVersion=${developmentVersion.toString()} \
75-
-Prelease \
76-
"""
77-
sh """ \
78-
./mvnw release:perform ${params.RELEASE_DRY_RUN ? '-DdryRun' : ''} -Prelease \
79-
"""
80-
}
81-
}
82-
}
83-
}
84-
}
85-
}
8625
}
87-
}
26+
}

ci/release/Jenkinsfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
@Library('[email protected]') _
2+
3+
import org.hibernate.jenkins.pipeline.helpers.version.Version
4+
5+
pipeline {
6+
agent {
7+
label 'Worker&&Containers'
8+
}
9+
tools {
10+
maven 'Apache Maven 3.8'
11+
jdk 'OpenJDK 17 Latest'
12+
}
13+
options {
14+
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
15+
disableConcurrentBuilds(abortPrevious: false)
16+
}
17+
parameters {
18+
string(
19+
name: 'RELEASE_VERSION',
20+
defaultValue: '',
21+
description: 'The version to be released, e.g. 1.0.0.Final.',
22+
trim: true
23+
)
24+
string(
25+
name: 'DEVELOPMENT_VERSION',
26+
defaultValue: '',
27+
description: 'The next version to be used after the release, e.g. 1.0.1-SNAPSHOT.',
28+
trim: true
29+
)
30+
booleanParam(
31+
name: 'RELEASE_DRY_RUN',
32+
defaultValue: false,
33+
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts.'
34+
)
35+
}
36+
stages {
37+
stage('Release') {
38+
when {
39+
beforeAgent true
40+
// Releases must be triggered explicitly with parameters
41+
expression { return params.RELEASE_VERSION }
42+
}
43+
steps {
44+
script {
45+
// Check that all the necessary parameters are set
46+
if (!params.RELEASE_VERSION) {
47+
throw new IllegalArgumentException("Missing value for parameter RELEASE_VERSION.")
48+
}
49+
if (!params.DEVELOPMENT_VERSION) {
50+
throw new IllegalArgumentException("Missing value for parameter DEVELOPMENT_VERSION.")
51+
}
52+
53+
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
54+
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
55+
echo "Performing full release for version ${releaseVersion.toString()}"
56+
57+
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
58+
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
59+
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
60+
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
61+
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
62+
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
63+
string(credentialsId: 'release.gpg.passphrase', variable: 'MAVEN_GPG_PASSPHRASE')]) {
64+
sshagent(['ed25519.Hibernate-CI.github.com']) {
65+
sh 'mvn -v'
66+
sh 'cat $HOME/.ssh/config'
67+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
68+
env.RELEASE_GPG_HOMEDIR = env.WORKSPACE_TMP + '/.gpg'
69+
sh """
70+
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
71+
infra-develocity ${releaseVersion.toString()} ${developmentVersion.toString()}
72+
"""
73+
}
74+
}
75+
}
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}

pom.xml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
<maven.compiler.source>17</maven.compiler.source>
2323
<maven.compiler.release>17</maven.compiler.release>
2424
<maven.compiler.parameters>true</maven.compiler.parameters>
25-
<maven-release-plugin.version>3.1.1</maven-release-plugin.version>
2625
<nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
2726
<maven-javadoc-plugin.version>3.11.1</maven-javadoc-plugin.version>
2827
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
2928
<maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
29+
<version.gpg.plugin>3.2.7</version.gpg.plugin>
30+
31+
<gpg.sign.skip>true</gpg.sign.skip>
3032

3133
<!-- Repository Deployment URLs -->
3234
<ossrh.releases.repo.id>ossrh</ossrh.releases.repo.id>
@@ -152,6 +154,25 @@
152154
</transformers>
153155
</configuration>
154156
</plugin>
157+
<plugin>
158+
<groupId>org.apache.maven.plugins</groupId>
159+
<artifactId>maven-gpg-plugin</artifactId>
160+
<version>${version.gpg.plugin}</version>
161+
<executions>
162+
<execution>
163+
<id>sign-artifacts</id>
164+
<phase>verify</phase>
165+
<goals>
166+
<goal>sign</goal>
167+
</goals>
168+
<configuration>
169+
<skip>${gpg.sign.skip}</skip>
170+
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
171+
<bestPractices>true</bestPractices>
172+
</configuration>
173+
</execution>
174+
</executions>
175+
</plugin>
155176
</plugins>
156177
</build>
157178

@@ -206,18 +227,17 @@
206227
<profiles>
207228
<profile>
208229
<id>release</id>
230+
<activation>
231+
<property>
232+
<name>performRelease</name>
233+
<value>true</value>
234+
</property>
235+
</activation>
236+
<properties>
237+
<gpg.sign.skip>false</gpg.sign.skip>
238+
</properties>
209239
<build>
210240
<plugins>
211-
<plugin>
212-
<groupId>org.apache.maven.plugins</groupId>
213-
<artifactId>maven-release-plugin</artifactId>
214-
<version>${maven-release-plugin.version}</version>
215-
<configuration>
216-
<autoVersionSubmodules>true</autoVersionSubmodules>
217-
<tagNameFormat>@{project.version}</tagNameFormat>
218-
<localCheckout>true</localCheckout>
219-
</configuration>
220-
</plugin>
221241
<plugin>
222242
<groupId>org.sonatype.plugins</groupId>
223243
<artifactId>nexus-staging-maven-plugin</artifactId>

0 commit comments

Comments
 (0)