From ef3270e32c50cd422326379be3ab73e96e045256 Mon Sep 17 00:00:00 2001 From: Ramzi El-Yafi Date: Thu, 28 May 2020 22:34:37 +0100 Subject: [PATCH] [INFRA-352] Artifactory publication in Jenkins (#6276) (#6290) * [INFRA-352] Artifactory publication in Jenkins * Address review comments --- .ci/dev/publish-branch/Jenkinsfile.nightly | 69 ++++++++++++++++++++++ .ci/dev/publish-branch/Jenkinsfile.preview | 65 ++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 .ci/dev/publish-branch/Jenkinsfile.nightly create mode 100644 .ci/dev/publish-branch/Jenkinsfile.preview diff --git a/.ci/dev/publish-branch/Jenkinsfile.nightly b/.ci/dev/publish-branch/Jenkinsfile.nightly new file mode 100644 index 0000000000..460117e500 --- /dev/null +++ b/.ci/dev/publish-branch/Jenkinsfile.nightly @@ -0,0 +1,69 @@ +#!groovy +@Library('corda-shared-build-pipeline-steps') +import static com.r3.build.BuildControl.killAllExistingBuildsForJob + +killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger()) + +pipeline { + agent { label 'k8s' } + + options { + timestamps() + ansiColor('xterm') + overrideIndexTriggers(false) + buildDiscarder(logRotator(daysToKeepStr: '7', artifactDaysToKeepStr: '7')) + timeout(time: 3, unit: 'HOURS') + } + + 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("/", " :: ") + } + + stages { + 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 + ) + } + } + } + + + post { + cleanup { + deleteDir() /* clean up our workspace */ + } + } +} diff --git a/.ci/dev/publish-branch/Jenkinsfile.preview b/.ci/dev/publish-branch/Jenkinsfile.preview new file mode 100644 index 0000000000..1b39ae3237 --- /dev/null +++ b/.ci/dev/publish-branch/Jenkinsfile.preview @@ -0,0 +1,65 @@ +#!groovy +@Library('corda-shared-build-pipeline-steps') +import static com.r3.build.BuildControl.killAllExistingBuildsForJob + +killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger()) + +pipeline { + agent { label 'k8s' } + + options { + timestamps() + ansiColor('xterm') + overrideIndexTriggers(false) + buildDiscarder(logRotator(daysToKeepStr: '7', artifactDaysToKeepStr: '7')) + timeout(time: 3, unit: 'HOURS') + } + + environment { + // Replace / with :: as links from Jenkins to Artifactory are broken if we use slashes + // in the name + ARTIFACTORY_BUILD_NAME = "Corda / Publish / Publish Preview to Artifactory" + .replaceAll("/", " :: ") + } + + stages { + 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 -PversionFromGit", + tasks: 'artifactoryPublish', + deployerId: 'deployer', + buildName: env.ARTIFACTORY_BUILD_NAME + ) + } + rtPublishBuildInfo ( + serverId: 'R3-Artifactory', + buildName: env.ARTIFACTORY_BUILD_NAME + ) + } + } + } + + + post { + cleanup { + deleteDir() /* clean up our workspace */ + } + } +}