Changing ci pipeline settings

Better isolation of workspaces and repositories
This commit is contained in:
Martin Stockhammer 2018-11-01 19:08:44 +01:00
parent 88c991837a
commit d8b6d1ce00
2 changed files with 41 additions and 21 deletions

46
Jenkinsfile vendored
View File

@ -33,6 +33,7 @@ buildJdk9 = 'JDK 1.9 (latest)'
buildJdk10 = 'JDK 10 (latest)' buildJdk10 = 'JDK 10 (latest)'
buildMvn = 'Maven 3.5.2' buildMvn = 'Maven 3.5.2'
deploySettings = 'archiva-uid-jenkins' deploySettings = 'archiva-uid-jenkins'
localRepository = "../.archiva-master-repository"
INTEGRATION_PIPELINE = "Archiva-IntegrationTests-Gitbox" INTEGRATION_PIPELINE = "Archiva-IntegrationTests-Gitbox"
@ -40,22 +41,39 @@ pipeline {
agent { agent {
label "${LABEL}" label "${LABEL}"
} }
options {
disableConcurrentBuilds()
}
parameters {
booleanParam(name: 'PRECLEANUP', defaultValue: false, description: 'Clears the local maven repository before build.')
}
stages { stages {
stage('PreCleanup') {
when {
expression {
params.PRECLEANUP
}
}
steps {
sh "rm -rf ${localRepository}"
}
}
stage('BuildAndDeploy') { stage('BuildAndDeploy') {
environment { environment {
ARCHIVA_USER_CONFIG_FILE = '/tmp/archiva-master-jdk-8-${env.JOB_NAME}.xml' ARCHIVA_USER_CONFIG_FILE = '/tmp/archiva-master-jdk-8-${env.JOB_NAME}.xml'
} }
steps { steps {
timeout(120) { timeout(120) {
withMaven(maven: buildMvn, jdk: buildJdk, withMaven(maven: buildMvn, jdk: buildJdk,
mavenSettingsConfig: deploySettings, mavenSettingsConfig: deploySettings,
mavenLocalRepo: ".repository", mavenLocalRepo: localRepository,
options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true), options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
findbugsPublisher(disabled: true), artifactsPublisher(disabled: false), findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
invokerPublisher(disabled: true), jgivenPublisher(disabled: true), invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
junitPublisher(disabled: false, ignoreAttachments: false), junitPublisher(disabled: false, ignoreAttachments: false),
openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)] openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
@ -75,7 +93,7 @@ pipeline {
// -Dmaven.compiler.fork=true: Do compile in a separate forked process // -Dmaven.compiler.fork=true: Do compile in a separate forked process
// -Dmaven.test.failure.ignore=true: Do not stop, if some tests fail // -Dmaven.test.failure.ignore=true: Do not stop, if some tests fail
// -Pci-build: Profile for CI-Server // -Pci-build: Profile for CI-Server
sh "mvn clean deploy -B -U -e -fae -T1C -Dmaven.compiler.fork=true -Pci-build" sh "mvn clean deploy -B -U -e -fae -Dmaven.compiler.fork=true -Pci-build"
} }
} }
} }
@ -86,7 +104,6 @@ pipeline {
} }
success { success {
archiveArtifacts '**/target/*.war,**/target/*-bin.zip' archiveArtifacts '**/target/*.war,**/target/*-bin.zip'
stash(name:'archiva-master-build-ws')
} }
failure { failure {
notifyBuild("Failure in BuildAndDeploy stage") notifyBuild("Failure in BuildAndDeploy stage")
@ -100,7 +117,7 @@ pipeline {
parallel { parallel {
stage('IntegrationTest') { stage('IntegrationTest') {
steps { steps {
build(job: "${INTEGRATION_PIPELINE}/archiva/${env.BRANCH_NAME}", propagate: false, quietPeriod: 10) build(job: "${INTEGRATION_PIPELINE}/archiva/${env.BRANCH_NAME}", propagate: false, quietPeriod: 5, wait: false)
} }
} }
stage('JDK9') { stage('JDK9') {
@ -109,7 +126,7 @@ pipeline {
} }
steps { steps {
ws("${env.JOB_NAME}-JDK9") { ws("${env.JOB_NAME}-JDK9") {
unstash(name:'archiva-master-build-ws') checkout scm
timeout(120) { timeout(120) {
withMaven(maven: buildMvn, jdk: buildJdk9, withMaven(maven: buildMvn, jdk: buildJdk9,
mavenSettingsConfig: deploySettings, mavenSettingsConfig: deploySettings,
@ -121,7 +138,7 @@ pipeline {
openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)] openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
) )
{ {
sh "mvn clean install -B -e -fae -T1C -Dmaven.compiler.fork=true -Pci-build" sh "mvn clean install -U -B -e -fae -Dmaven.compiler.fork=true -Pci-build"
} }
} }
} }
@ -130,6 +147,9 @@ pipeline {
always { always {
sh "rm -f /tmp/archiva-master-jdk-9-${env.JOB_NAME}.xml" sh "rm -f /tmp/archiva-master-jdk-9-${env.JOB_NAME}.xml"
} }
success {
cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.repository', type: 'EXCLUDE']]
}
} }
} }
stage('JDK10') { stage('JDK10') {
@ -138,7 +158,7 @@ pipeline {
} }
steps { steps {
ws("${env.JOB_NAME}-JDK10") { ws("${env.JOB_NAME}-JDK10") {
unstash(name:'archiva-master-build-ws') checkout scm
timeout(120) { timeout(120) {
withMaven(maven: buildMvn, jdk: buildJdk10, withMaven(maven: buildMvn, jdk: buildJdk10,
mavenSettingsConfig: deploySettings, mavenSettingsConfig: deploySettings,
@ -150,7 +170,7 @@ pipeline {
openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)] openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
) )
{ {
sh "mvn clean install -B -e -fae -T1C -Dmaven.compiler.fork=true -Pci-build" sh "mvn clean install -U -B -e -fae -Dmaven.compiler.fork=true -Pci-build"
} }
} }
} }
@ -159,6 +179,9 @@ pipeline {
always { always {
sh "rm -f /tmp/archiva-master-jdk-10-${env.JOB_NAME}.xml" sh "rm -f /tmp/archiva-master-jdk-10-${env.JOB_NAME}.xml"
} }
success {
cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.repository', type: 'EXCLUDE']]
}
} }
} }
} }
@ -178,9 +201,6 @@ pipeline {
} }
} }
} }
always {
cleanWs()
}
} }
} }

View File

@ -29,6 +29,7 @@ buildJdk = 'JDK 1.8 (latest)'
buildMvn = 'Maven 3.5.2' buildMvn = 'Maven 3.5.2'
deploySettings = 'archiva-uid-jenkins' deploySettings = 'archiva-uid-jenkins'
DOCKERHUB_CREDS = '10a5f89e-504b-11e8-945d-7fd7b29cc41c' DOCKERHUB_CREDS = '10a5f89e-504b-11e8-945d-7fd7b29cc41c'
localRepository = "../.archiva-master-repository"
pipeline { pipeline {
agent { agent {
@ -57,7 +58,7 @@ pipeline {
timeout(120) { timeout(120) {
withMaven(maven: buildMvn, jdk: buildJdk, withMaven(maven: buildMvn, jdk: buildJdk,
mavenSettingsConfig: deploySettings, mavenSettingsConfig: deploySettings,
mavenLocalRepo: ".repository", mavenLocalRepo: localRepository,
options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true), options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
findbugsPublisher(disabled: true), artifactsPublisher(disabled: true), findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
invokerPublisher(disabled: true), jgivenPublisher(disabled: true), invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
@ -79,8 +80,7 @@ pipeline {
// -Dmaven.compiler.fork=true: Compile in a separate forked process // -Dmaven.compiler.fork=true: Compile in a separate forked process
// -Pci-server: Profile for CI-Server // -Pci-server: Profile for CI-Server
// -Pit-js: Run the selenium test // -Pit-js: Run the selenium test
sh "mvn clean install -B -U -Dmaven.test.skip=true -T2" sh "mvn clean verify -B -V -U -e -fae -Dmaven.compiler.fork=true -DmaxWaitTimeInMs=2000 -Pci-server -Pit-js -DtrimStackTrace=false -Djava.io.tmpdir=.tmp -pl :archiva-webapp-test"
sh "mvn clean install -B -V -U -e -fae -Dmaven.compiler.fork=true -DmaxWaitTimeInMs=2000 -Pci-server -Pit-js -DtrimStackTrace=false -Djava.io.tmpdir=.tmp -pl :archiva-webapp-test"
} }
} }
@ -104,7 +104,7 @@ pipeline {
usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PW']]) { usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PW']]) {
withMaven(maven: buildMvn, jdk: buildJdk, withMaven(maven: buildMvn, jdk: buildJdk,
mavenSettingsConfig: deploySettings, mavenSettingsConfig: deploySettings,
mavenLocalRepo: ".repository", mavenLocalRepo: localRepository,
options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true), options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
findbugsPublisher(disabled: true), artifactsPublisher(disabled: true), findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
invokerPublisher(disabled: true), jgivenPublisher(disabled: true), invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
@ -128,7 +128,7 @@ pipeline {
// -Pci-server: Profile for CI Server // -Pci-server: Profile for CI Server
// -Pit-js: Runs the Selenium tests // -Pit-js: Runs the Selenium tests
// -Pchrome: Activates the Selenium Chrome Test Agent // -Pchrome: Activates the Selenium Chrome Test Agent
sh "mvn clean install -B -V -U -e -fae -Dmaven.compiler.fork=true -DmaxWaitTimeInMs=2000 -DseleniumRemote=true -Pci-server -Pit-js -Pchrome -pl :archiva-webapp-test -DtrimStackTrace=false" sh "mvn verify -B -V -e -fae -Dmaven.compiler.fork=true -DmaxWaitTimeInMs=2000 -DseleniumRemote=true -Pci-server -Pit-js -Pchrome -pl :archiva-webapp-test -DtrimStackTrace=false"
} }
} }
} }