|
1 | | -node { |
2 | | - stage('Prepare Environment') { |
3 | | - def mvnHome = tool 'Maven 3.3.9' |
4 | | - def javaHome = tool 'Oracle JDK 8' |
5 | | - env.JAVA_HOME="${javaHome}" |
6 | | - env.MAVEN_HOME="${mvnHome}" |
7 | | - env.PATH="${env.JAVA_HOME}/bin:${env.MAVEN_HOME}/bin:${env.PATH}" |
8 | | - } |
| 1 | +// must be executed on a docker-enabled node |
| 2 | +node('docker-based-builds') { |
| 3 | + |
| 4 | + // check out branch that triggered the build |
9 | 5 | stage('Checkout SCM') { |
10 | 6 | checkout scm |
11 | 7 | } |
12 | | - stage('Set Version to $VERSION') { |
13 | | - dir('webtester-build-tools') { |
| 8 | + |
| 9 | + // load build environment docker container |
| 10 | + def container = docker.image('caaqe/webtester2-build-environment:latest') |
| 11 | + container.pull() |
| 12 | + container.inside { |
| 13 | + |
| 14 | + stage('Log Tool Versions') { |
| 15 | + sh 'java -version' |
| 16 | + sh 'git --version' |
| 17 | + sh 'mvn --version' |
| 18 | + sh 'gpg --version' |
| 19 | + } |
| 20 | + |
| 21 | + stage('Set Version to $VERSION') { |
| 22 | + sh 'cd webtester-build-tools && mvn versions:set versions:commit -DnewVersion=$VERSION' |
14 | 23 | sh 'mvn versions:set versions:commit -DnewVersion=$VERSION' |
15 | 24 | } |
16 | | - sh 'mvn versions:set versions:commit -DnewVersion=$VERSION' |
17 | | - } |
18 | | - stage('Build & Deploy to Sonatype OSS') { |
19 | | - withCredentials([string(credentialsId: 'webtester-gpg-passphrase', variable: 'GPG_PASSPHRASE')]) { |
20 | | - def skipTests = "-DskipUnitTests=true -DskipIntegrationTests=true" |
21 | | - def gpgPassphrase = "-Dgpg.passphrase=$GPG_PASSPHRASE" |
22 | | - def profiles = "-P documentation,release,maven-central" |
23 | | - sh "mvn clean deploy ${skipTests} ${gpgPassphrase} ${profiles}" |
| 25 | + |
| 26 | + stage('Build & Deploy to Sonatype OSS') { |
| 27 | + // credentials for the repository are stored in Jenkins |
| 28 | + withCredentials([usernamePassword(credentialsId: 'ossrh-credentials', passwordVariable: 'ossrhPassword', usernameVariable: 'ossrhUsername')]) { |
| 29 | + // credentials for the GPG certificates are stored in Jenkins |
| 30 | + withCredentials([string(credentialsId: 'webtester-gpg-passphrase', variable: 'gpgPassphrase')]) { |
| 31 | + |
| 32 | + def skipTests = "-DskipUnitTests=true -DskipIntegrationTests=true" |
| 33 | + def gpgPassphrase = "-Dgpg.passphrase=${gpgPassphrase}" |
| 34 | + def repositoryCredentials = "-Dossrh.username=${ossrhUsername} -Dossrh.password=${ossrhPassword}" |
| 35 | + def profiles = "-P documentation,release,maven-central" |
| 36 | + |
| 37 | + sh "mvn clean deploy ${skipTests} ${gpgPassphrase} ${repositoryCredentials} ${profiles}" |
| 38 | + |
| 39 | + } |
| 40 | + } |
24 | 41 | } |
| 42 | + |
25 | 43 | } |
| 44 | + |
26 | 45 | } |
0 commit comments