pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
parameters {
string(name: 'DEPLOY_MESSAGE', defaultValue: 'Deploy ?', description: 'Message de déploiement')
}
environment {
FORCE_DEPLOY = 'false'
}
stages {
stage('Build') {
agent {
dockerfile {
filename 'Dockerfile.build'
label 'docker'
additionalBuildArgs '--build-arg HTTP_PROXY=http://10.0.4.2:3128/ --build-arg HTTPS_PROXY=http://10.0.4.2:3128/'
}
}
steps {
sh './scripts/build.sh'
}
post {
always {
junit 'target/surefire-reports/**/*.xml'
}
success {
archiveArtifacts 'target/*.jar'
stash(name: 'build-result', includes: 'target/**/*')
}
}
}
stage('Test') {
parallel {
stage('Test Java 8') {
agent {
node {
label 'java8'
}
}
steps {
unstash 'build-result'
sh './scripts/integration-tests.sh'
junit 'target/failsafe-reports/**/*.xml'
}
}
stage('Test Java 12') {
agent {
node {
label 'java12'
}
}
steps {
unstash 'build-result'
sh './scripts/integration-tests.sh'
junit 'target/failsafe-reports/**/*.xml'
}
}
}
}
stage('Approval') {
agent none
steps {
timeout(time: 3, unit: 'MINUTES') {
input(message: params.DEPLOY_MESSAGE, ok: 'Yes Deploy!')
}
}
when {
anyOf {
branch 'master'
environment name: 'FORCE_DEPLOY', value: 'true'
}
}
}
stage('Deploy') {
steps {
sh './scripts/deploy.sh'
}
when {
anyOf {
branch 'master'
environment name: 'FORCE_DEPLOY', value: 'true'
}
}
}
}
}