Skip to content

Commit 64d1372

Browse files
committed
Jenkins: Prepare release to central
1 parent 5da2674 commit 64d1372

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

Jenkinsfile

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ node {
2727
git.clean('')
2828
}
2929

30+
initMaven(mvn)
31+
3032
stage('Build') {
3133
mvn 'clean install -DskipTests'
3234
archive '**/target/*.jar'
@@ -39,14 +41,58 @@ node {
3941
stage('Integration Test') {
4042
mvn 'verify -DskipUnitTests'
4143
}
44+
45+
stage('Deploy') {
46+
if (preconditionsForDeploymentFulfilled()) {
47+
48+
mvn.setDeploymentRepository('ossrh', 'https://oss.sonatype.org/', 'de.triology-mavenCentral-acccessToken')
49+
50+
mvn.setSignatureCredentials('de.triology-mavenCentral-secretKey-asc-file',
51+
'de.triology-mavenCentral-secretKey-Passphrase')
52+
53+
mvn.deployToNexusRepositoryWithStaging()
54+
}
55+
}
4256
}
4357

4458
// Archive Unit and integration test results, if any
4559
junit allowEmptyResults: true,
46-
testResults: '**/target/surefire-reports/TEST-*.xml, **/target/failsafe-reports/*.xml'
60+
testResults: '**/target/surefire-reports/TEST-*.xml, **/target/failsafe-reports/*.xml'
4761

4862
// Find maven warnings and visualize in job
4963
warnings consoleParsers: [[parserName: 'Maven']]
5064

5165
mailIfStatusChanged(git.commitAuthorEmail)
5266
}
67+
68+
boolean preconditionsForDeploymentFulfilled() {
69+
if (isBuildSuccessful() &&
70+
!isPullRequest() &&
71+
shouldBranchBeDeployed()) {
72+
return true
73+
} else {
74+
echo "Skipping deployment because of branch or build result: currentResult=${currentBuild.currentResult}, " +
75+
"result=${currentBuild.result}, branch=${env.BRANCH_NAME}."
76+
return false
77+
}
78+
}
79+
80+
private boolean shouldBranchBeDeployed() {
81+
return env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'develop'
82+
}
83+
84+
private boolean isBuildSuccessful() {
85+
currentBuild.currentResult == 'SUCCESS' &&
86+
// Build result == SUCCESS seems not to set be during pipeline execution.
87+
(currentBuild.result == null || currentBuild.result == 'SUCCESS')
88+
}
89+
90+
void initMaven(Maven mvn) {
91+
92+
if ("master".equals(env.BRANCH_NAME)) {
93+
94+
echo "Building master branch"
95+
mvn.additionalArgs = "-DperformRelease"
96+
currentBuild.description = mvn.getVersion()
97+
}
98+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2828
<modelVersion>4.0.0</modelVersion>
2929

30-
<groupId>com.github.triologygmbh</groupId>
30+
<groupId>de.triology.test-data-loader</groupId>
3131
<artifactId>test-data-loader</artifactId>
3232
<version>0.2.2-SNAPSHOT</version>
3333

0 commit comments

Comments
 (0)