-
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 (#591)
- Loading branch information
Showing
10 changed files
with
49 additions
and
129 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,122 +1,14 @@ | ||
#!groovy | ||
/** | ||
* Jenkins pipeline to build Corda Gradle Plugins | ||
*/ | ||
|
||
/** | ||
* 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\/.*/) | ||
|
||
boolean isBeta = (env.TAG_NAME =~ /^beta\/.*/) | ||
|
||
boolean doPublish = isReleaseBranch || isRelease || isBeta | ||
|
||
pipeline { | ||
agent { | ||
label 'standard' | ||
} | ||
parameters { | ||
booleanParam name: 'DO_PUBLISH', | ||
defaultValue: doPublish, | ||
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 || isBeta ? "corda-releases" : "corda-dev"}" | ||
ARTIFACTORY_CREDENTIALS = credentials('artifactory-credentials') | ||
CORDA_ARTIFACTORY_USERNAME = "${env.ARTIFACTORY_CREDENTIALS_USR}" | ||
CORDA_ARTIFACTORY_PASSWORD = "${env.ARTIFACTORY_CREDENTIALS_PSW}" | ||
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 --info --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, | ||
) | ||
rtGradleRun ( | ||
usesPlugin: true, | ||
useWrapper: true, | ||
switches: "--no-daemon --info -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() | ||
} | ||
} | ||
} | ||
|
||
def isReleaseBranch() { | ||
return (env.BRANCH_NAME =~ /^release\/.*$/) | ||
} | ||
|
||
def isMainBranch() { | ||
return (env.BRANCH_NAME =~ /^master$/) | ||
} | ||
@Library('[email protected]') _ | ||
|
||
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
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,9 +1,9 @@ | ||
repositories { | ||
mavenCentral() | ||
maven { | ||
url 'https://software.r3.com/artifactory/corda-dependencies-dev' | ||
url "$publicArtifactURL/corda-dependencies-dev" | ||
} | ||
maven { | ||
url 'https://software.r3.com/artifactory/corda-dependencies' | ||
url "$publicArtifactURL/corda-dependencies" | ||
} | ||
} |