Skip to content

Commit

Permalink
ES-858: Update Corda Gradle plugins to use shared lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgovc committed Jul 20, 2023
1 parent f4e740a commit 21c45b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 111 deletions.
124 changes: 13 additions & 111 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,111 +1,13 @@
#!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\/.*/)

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()
}
}
}
@Library('[email protected]') _
cordaPipeline(
dedicatedJobForSnykDelta: false,
javaVersion: '8',
publishToMavenS3Repository: true,
publishRepoPrefix: 'corda',
slimBuild: true,
stableUnstableRepoPattern: false,
nexusAppId :'corda-gradle-plugins-7.0.0',
snykAdditionalCommands: "--configuration-matching='^runtimeClasspath\$' -d",
gitHubComments: false,
snykIntegrationId: 'r3-gradle-plugins'
)
7 changes: 7 additions & 0 deletions .ci/nightly/JenkinsfileSnykScan
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@Library('[email protected]') _

cordaSnykScanPipeline (
snykTokenId: 'r3-gradle-plugins',
snykAdditionalCommands: "--all-sub-projects --configuration-matching='^runtimeClasspath\$' -d"
)

0 comments on commit 21c45b6

Please sign in to comment.