2020-05-28 22:34:37 +01:00
#!groovy
2020-07-22 19:43:08 +01:00
/**
* Jenkins pipeline to build Corda OS nightly snapshots
*/
/**
* Kill already started job.
* Assume new commit takes precendence and results from previous
* unfinished builds are not required.
* This feature doesn't play well with disableConcurrentBuilds() option
*/
2020-05-28 22:34:37 +01:00
@Library('corda-shared-build-pipeline-steps')
import static com.r3.build.BuildControl.killAllExistingBuildsForJob
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
2020-07-22 19:43:08 +01:00
/*
** calculate the stage for NexusIQ evaluation
** * build for snapshots
*/
2020-08-07 06:07:29 +02:00
def nexusDefaultIqStage = "build"
2020-07-22 19:43:08 +01:00
2020-08-06 20:20:19 +01:00
/**
* make sure calculated default value of NexusIQ stage is first in the list
* thus making it default for the `choice` parameter
*/
def nexusIqStageChoices = [nexusDefaultIqStage].plus(
[
'develop',
'build',
'stage-release',
'release',
'operate'
].minus([nexusDefaultIqStage]))
2020-05-28 22:34:37 +01:00
pipeline {
2020-07-22 19:43:08 +01:00
agent { label 'standard' }
2020-05-28 22:34:37 +01:00
options {
timestamps()
ansiColor('xterm')
overrideIndexTriggers(false)
timeout(time: 3, unit: 'HOURS')
2020-07-15 10:17:58 +01:00
buildDiscarder(logRotator(daysToKeepStr: '14', artifactDaysToKeepStr: '14'))
2020-05-28 22:34:37 +01:00
}
2020-08-07 06:07:29 +02:00
parameters {
choice choices: nexusIqStageChoices, description: 'NexusIQ stage for code evaluation', name: 'nexusIqStage'
}
2020-05-28 22:34:37 +01:00
triggers {
cron '@midnight'
}
environment {
// Replace / with :: as links from Jenkins to Artifactory are broken if we use slashes
// in the name
ARTIFACTORY_BUILD_NAME = "Corda / Publish / Publish Nightly to Artifactory"
.replaceAll("/", " :: ")
2020-06-30 20:12:27 +01:00
DOCKER_URL = "https://index.docker.io/v1/"
2020-05-28 22:34:37 +01:00
}
stages {
2020-07-22 19:43:08 +01:00
stage('Sonatype Check') {
steps {
sh "./gradlew --no-daemon clean jar"
script {
sh "./gradlew --no-daemon properties | grep -E '^(version|group):' >version-properties"
2020-07-22 19:54:41 +01:00
/* every build related to Corda X.Y (GA, RC, HC, patch or snapshot) uses the same NexusIQ application */
2020-11-16 08:18:22 +01:00
def version = sh (returnStdout: true, script: "grep ^version: version-properties | sed -e 's/^version: \\([0-9]\\+\\(\\.[0-9]\\+\\)\\+\\).*\$/\\1/'").trim()
2020-07-22 19:43:08 +01:00
def groupId = sh (returnStdout: true, script: "grep ^group: version-properties | sed -e 's/^group: //'").trim()
def artifactId = 'corda'
2020-08-06 20:17:15 +01:00
nexusAppId = "${groupId}-${artifactId}-${version}"
2020-07-22 19:43:08 +01:00
}
nexusPolicyEvaluation (
failBuildOnNetworkError: false,
2020-07-22 19:54:41 +01:00
iqApplication: selectedApplication(nexusAppId), // application *has* to exist before a build starts!
2020-07-22 19:43:08 +01:00
iqScanPatterns: [[scanPattern: 'node/capsule/build/libs/corda*.jar']],
2020-08-06 20:20:19 +01:00
iqStage: params.nexusIqStage
2020-07-22 19:43:08 +01:00
)
}
}
2020-05-28 22:34:37 +01:00
stage('Publish to Artifactory') {
steps {
rtServer (
id: 'R3-Artifactory',
url: 'https://software.r3.com/artifactory',
credentialsId: 'artifactory-credentials'
)
rtGradleDeployer (
id: 'deployer',
serverId: 'R3-Artifactory',
repo: 'corda-dev',
)
withCredentials([
usernamePassword(credentialsId: 'artifactory-credentials',
usernameVariable: 'CORDA_ARTIFACTORY_USERNAME',
passwordVariable: 'CORDA_ARTIFACTORY_PASSWORD')]) {
rtGradleRun (
usesPlugin: true,
useWrapper: true,
switches: "--no-daemon -s",
tasks: 'artifactoryPublish',
deployerId: 'deployer',
buildName: env.ARTIFACTORY_BUILD_NAME
)
}
rtPublishBuildInfo (
serverId: 'R3-Artifactory',
buildName: env.ARTIFACTORY_BUILD_NAME
)
}
}
2020-06-30 20:12:27 +01:00
stage('Publish Nightly to Docker Hub') {
steps {
withCredentials([
usernamePassword(credentialsId: 'corda-publisher-docker-hub-credentials',
usernameVariable: 'DOCKER_USERNAME',
passwordVariable: 'DOCKER_PASSWORD')]) {
2020-11-24 17:36:53 +00:00
sh script: [
'./gradlew',
'docker:pushDockerImage',
'-Pdocker.image.repository=corda/corda',
2020-11-26 13:47:35 +00:00
'--image OFFICIAL'
2020-11-24 17:36:53 +00:00
].join(' ')
2020-06-30 20:12:27 +01:00
}
}
}
2020-05-28 22:34:37 +01:00
}
post {
cleanup {
deleteDir() /* clean up our workspace */
}
}
}