Skip to content

Commit

Permalink
Use different Jenkins stage for klass-api vs klass-forvaltning (#157)
Browse files Browse the repository at this point in the history
* Use different build stages in Jenkins for klass-api vs klass-forvaltning
  • Loading branch information
bjornandre authored Jan 24, 2024
1 parent a61b0ab commit 172738d
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,51 @@ pipeline {
pollSCM('H/5 * * * *')
}

tools {
jdk 'OpenJDK Java 17'
maven 'Maven 3.5.2'
git 'Default'
}

parameters {
booleanParam(name: "RELEASE",
description: "Build a release from current commit.",
defaultValue: false)
}

parameters {
booleanParam(name: "RELEASE",
description: "Build a release from current commit.",
defaultValue: false)

choice(name: 'ARTIFACT',
choices: ['klass-api', 'klass-forvaltning'],
description: 'Name of artifact to build and deploy.'
)
}

tools {
maven 'Maven 3.5.2'
git 'Default'
}

stages {

stage("Build & deploy SNAPSHOT to Nexus") {
stage("Build & deploy SNAPSHOT of klass-api to Nexus") {
when {
expression { params.ARTIFACT == 'klass-api' }
}
tools {
jdk 'OpenJDK Java 17'
}
steps {
sh "mvn -B clean deploy -Pdocumentation -pl :klass-api -am"
}
}

stage("Build & deploy RELEASE to Nexus") {
stage("Build & deploy SNAPSHOT of klass-forvaltning to Nexus") {
when {
expression { params.RELEASE }
expression { params.ARTIFACT == 'klass-forvaltning' }
}
tools {
jdk 'Oracle Java 8'
}
steps {
sh "mvn -B clean deploy -Pdocumentation -Djava.version=1.8 -pl :klass-forvaltning -am"
}
}

stage("Build & deploy RELEASE of klass-api to Nexus") {
when {
expression { params.RELEASE && params.ARTIFACT == 'klass-api' }
}
steps {
sh "mvn -B -DpushChanges=false release:prepare"
Expand All @@ -49,5 +65,18 @@ pipeline {
}
}

stage("Build & deploy RELEASE of klass-forvaltning to Nexus") {
when {
expression { params.RELEASE && params.ARTIFACT == 'klass-forvaltning' }
}
steps {
sh "mvn -B -DpushChanges=false release:prepare"
sshagent(['605c16cc-7c0c-4d39-8c8a-6d190e2f98b1']) {
sh('git push --follow-tags')
}
sh "mvn -B release:perform -Djava.version=1.8 -pl :klass-forvaltning -am"
}
}

}
}

0 comments on commit 172738d

Please sign in to comment.