-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ES-858: Update Corda Gradle plugins post artifactory change (#590)
- Loading branch information
Showing
9 changed files
with
39 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,14 @@ | ||
#!groovy | ||
/** | ||
* Jenkins pipeline to build Corda Gradle Plugins | ||
*/ | ||
@Library('[email protected]') _ | ||
|
||
/** | ||
* Kill already started job. | ||
* Assume new commit takes precedence and results from previousunfinished builds are not required. | ||
* This feature doesn't play well with disableConcurrentBuilds() option | ||
*/ | ||
@Library('corda-shared-build-pipeline-steps') | ||
import static com.r3.build.BuildControl.killAllExistingBuildsForJob | ||
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger()) | ||
|
||
/** | ||
* Sense environment | ||
*/ | ||
boolean isReleaseBranch = (env.BRANCH_NAME =~ /^release\/.*/) | ||
boolean isRelease = (env.TAG_NAME =~ /^release\/.*/) | ||
|
||
pipeline { | ||
agent { | ||
label 'standard' | ||
} | ||
parameters { | ||
booleanParam name: 'DO_PUBLISH', | ||
defaultValue: (isReleaseBranch || isRelease), | ||
description: 'Publish artifacts to Artifactory?' | ||
} | ||
options { | ||
ansiColor('xterm') | ||
timestamps() | ||
timeout(3*60) // 3 hours | ||
buildDiscarder(logRotator(daysToKeepStr: '14', artifactDaysToKeepStr: '14')) | ||
} | ||
environment { | ||
// Replace / with :: as links from Jenkins to Artifactory are broken if we use slashes | ||
// in the name | ||
ARTIFACTORY_BUILD_NAME = "Corda Gradle Plugins / Publish To Artifactory" | ||
.replaceAll("/", " :: ") | ||
ARTIFACTORY_REPO = "${isRelease ? "corda-releases" : "corda-dev"}" | ||
SNYK_TOKEN = "r3-gradle-plugins" | ||
SNYK_COMMANDS = "--all-sub-projects --configuration-matching='^runtimeClasspath\$' --prune-repeated-subdependencies --target-reference='${env.BRANCH_NAME}' --project-tags=Branch='${env.BRANCH_NAME.replaceAll("[^0-9|a-z|A-Z]+","_")}'" | ||
} | ||
stages { | ||
stage('Build') { | ||
steps { | ||
authenticateGradleWrapper() | ||
sh './gradlew --no-daemon -s --no-build-cache clean build' | ||
} | ||
} | ||
stage('Snyk Security Scan') { | ||
when { | ||
not { | ||
changeRequest() | ||
} | ||
} | ||
steps { | ||
snykSecurityScan("${env.SNYK_TOKEN}", "${env.SNYK_COMMANDS}", true, true) | ||
} | ||
} | ||
stage('Publish to Artifactory') { | ||
when { | ||
expression { params.DO_PUBLISH } | ||
beforeAgent true | ||
} | ||
steps { | ||
rtServer ( | ||
id: 'R3-Artifactory', | ||
url: 'https://software.r3.com/artifactory', | ||
credentialsId: 'artifactory-credentials' | ||
) | ||
rtGradleDeployer ( | ||
id: 'deployer', | ||
serverId: 'R3-Artifactory', | ||
repo: env.ARTIFACTORY_REPO, | ||
) | ||
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 { | ||
always { | ||
script { | ||
if(!env.CHANGE_ID) { | ||
snykSecurityScan.generateHtmlElements() | ||
} | ||
} | ||
junit testResults: '**/build/test-results/**/*.xml', keepLongStdio: true, allowEmptyResults: true | ||
} | ||
cleanup { | ||
deleteDir() | ||
} | ||
} | ||
} | ||
cordaPipeline( | ||
dedicatedJobForSnykDelta: false, | ||
gitHubComments: false, | ||
javaVersion: '8', | ||
publishToMavenS3Repository: true, | ||
publishRepoPrefix: 'corda', | ||
slimBuild: true, | ||
snykAdditionalCommands: "--configuration-matching='^runtimeClasspath\$' -d", | ||
snykOrgId: 'r3-gradle-plugins-snyk-org-id', | ||
snykToken: 'r3-gradle-plugins-secret', | ||
stableUnstableRepoPattern: false, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@Library('[email protected]') _ | ||
|
||
cordaSnykScanPipeline ( | ||
snykTokenId: 'r3-gradle-plugins', | ||
snykAdditionalCommands: "--all-sub-projects --configuration-matching='^runtimeClasspath\$' -d" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters