diff --git a/Jenkinsfile b/Jenkinsfile index fa2ba36..5198e64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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" @@ -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" + } + } + } } \ No newline at end of file