|
| 1 | +def p = [:] |
| 2 | +node { |
| 3 | + checkout scm |
| 4 | + p = readProperties interpolate: true, file: 'ci/pipeline.properties' |
| 5 | +} |
| 6 | + |
| 7 | +pipeline { |
| 8 | + agent none |
| 9 | + |
| 10 | + triggers { |
| 11 | + pollSCM 'H/10 * * * *' |
| 12 | + } |
| 13 | + |
| 14 | + options { |
| 15 | + disableConcurrentBuilds() |
| 16 | + buildDiscarder(logRotator(numToKeepStr: '14')) |
| 17 | + } |
| 18 | + |
| 19 | + stages { |
| 20 | + stage("Docker images") { |
| 21 | + parallel { |
| 22 | + stage('Publish JDK 8 + Vault Docker image') { |
| 23 | + when { |
| 24 | + anyOf { |
| 25 | + changeset "ci/openjdk8-vault/Dockerfile" |
| 26 | + changeset "src/test/bash/install_vault.sh" |
| 27 | + changeset "ci/pipeline.properties" |
| 28 | + } |
| 29 | + } |
| 30 | + agent { label 'data' } |
| 31 | + options { timeout(time: 20, unit: 'MINUTES') } |
| 32 | + |
| 33 | + steps { |
| 34 | + script { |
| 35 | + def image = docker.build("${p['docker.build.image.name']}", "--build-arg BASE=${p['docker.java.main.image']} --build-arg VAULT=${p['docker.vault.version']} -f ci/openjdk8-vault/Dockerfile .") |
| 36 | + docker.withRegistry(p['docker.registry'], p['docker.credentials']) { |
| 37 | + image.push() |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + stage("test: baseline (Java 8)") { |
| 46 | + when { |
| 47 | + beforeAgent(true) |
| 48 | + anyOf { |
| 49 | + branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP") |
| 50 | + not { triggeredBy 'UpstreamCause' } |
| 51 | + } |
| 52 | + } |
| 53 | + agent { |
| 54 | + label 'data' |
| 55 | + } |
| 56 | + options { timeout(time: 30, unit: 'MINUTES') } |
| 57 | + environment { |
| 58 | + ARTIFACTORY = credentials("${p['artifactory.credentials']}") |
| 59 | + } |
| 60 | + steps { |
| 61 | + script { |
| 62 | + docker.image("${p['docker.image']}").inside(p['docker.java.inside.basic']) { |
| 63 | + sh 'src/test/bash/create_certificates.sh' |
| 64 | + sh '/opt/vault/vault server -config=$(pwd)/src/test/bash/vault.conf &' |
| 65 | + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml clean dependency:list verify -Dsort -U -B' |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + stage('Deploy') { |
| 72 | + when { |
| 73 | + beforeAgent(true) |
| 74 | + anyOf { |
| 75 | + branch(pattern: "main|(\\d\\.\\d\\.x)|v(\\d\\.\\d\\.d)|", comparator: "REGEXP") |
| 76 | + not { triggeredBy 'UpstreamCause' } |
| 77 | + } |
| 78 | + } |
| 79 | + agent { |
| 80 | + docker { |
| 81 | + image "${p['docker.image']}" |
| 82 | + args "${p['docker.java.inside.basic']}" |
| 83 | + } |
| 84 | + } |
| 85 | + options { timeout(time: 20, unit: 'MINUTES') } |
| 86 | + |
| 87 | + environment { |
| 88 | + ARTIFACTORY = credentials("${p['artifactory.credentials']}") |
| 89 | + SONATYPE = credentials('oss-login') |
| 90 | + KEYRING = credentials('spring-signing-secring.gpg') |
| 91 | + PASSPHRASE = credentials('spring-gpg-passphrase') |
| 92 | + } |
| 93 | + |
| 94 | + steps { |
| 95 | + script { |
| 96 | + PROJECT_VERSION = sh( |
| 97 | + script: "ci/version.sh", |
| 98 | + returnStdout: true |
| 99 | + ).trim() |
| 100 | + |
| 101 | + RELEASE_TYPE = 'snapshot' |
| 102 | + |
| 103 | + if (PROJECT_VERSION.matches(/.*-RC[0-9]+$/) || PROJECT_VERSION.matches(/.*-M[0-9]+$/)) { |
| 104 | + RELEASE_TYPE = "milestone" |
| 105 | + } else if (PROJECT_VERSION.endsWith('SNAPSHOT')) { |
| 106 | + RELEASE_TYPE = 'snapshot' |
| 107 | + } else if (PROJECT_VERSION.matches(/.*\.[0-9]+$/)) { |
| 108 | + RELEASE_TYPE = 'release' |
| 109 | + } |
| 110 | + |
| 111 | + sh "ci/deploy-${RELEASE_TYPE}.sh" |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + post { |
| 118 | + changed { |
| 119 | + script { |
| 120 | + emailext( |
| 121 | + subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}", |
| 122 | + mimeType: 'text/html', |
| 123 | + recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']], |
| 124 | + body: "<a href=\"${env.BUILD_URL}\">${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}</a>") |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | +} |
0 commit comments