|
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('Build & Deploy to Sonatype OSS') { |
13 | | - def skipTests = "-DskipUnitTests=true -DskipIntegrationTests=true" |
14 | | - def targetRepository = "-DaltDeploymentRepository=ossrh::default::https://oss.sonatype.org/content/repositories/snapshots" |
15 | | - def profiles = "-P documentation" |
16 | | - sh "mvn clean deploy ${skipTests} ${targetRepository} ${profiles}" |
| 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('Build & Deploy to Sonatype OSS') { |
| 22 | + |
| 23 | + // credentials for the repository are stored in Jenkins |
| 24 | + withCredentials([usernamePassword(credentialsId: 'ossrh-credentials', passwordVariable: 'ossrhPassword', usernameVariable: 'ossrhUsername')]) { |
| 25 | + |
| 26 | + def skipTests = "-DskipUnitTests=true -DskipIntegrationTests=true" |
| 27 | + def targetRepository = "-DaltDeploymentRepository=ossrh::default::https://oss.sonatype.org/content/repositories/snapshots" |
| 28 | + def repositoryCredentials = "-Dossrh.username=${ossrhUsername} -Dossrh.password=${ossrhPassword}" |
| 29 | + def profiles = "-P documentation" |
| 30 | + |
| 31 | + sh "mvn clean deploy ${skipTests} ${targetRepository} ${repositoryCredentials} ${profiles}" |
| 32 | + |
| 33 | + } |
| 34 | + |
| 35 | + } |
| 36 | + |
17 | 37 | } |
18 | 38 | } |
0 commit comments