Skip to content

Commit

Permalink
ES-858: Update Corda Gradle plugins post artifactory change (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgovc authored Jul 28, 2023
1 parent 1830277 commit cce1f4a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 116 deletions.
123 changes: 13 additions & 110 deletions .ci/Jenkinsfile
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,
)
6 changes: 6 additions & 0 deletions .ci/nightly/JenkinsfileSnykScan
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"
)
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ configure(publishProjects) { Project subproject ->
}
}
}
if (subproject.hasProperty('maven.repo.s3')) {
repositories {
maven {
name = 'AWS'
url = subproject.findProperty('maven.repo.s3')
credentials(AwsCredentials) {
accessKey "${System.getenv('AWS_ACCESS_KEY_ID')}"
secretKey "${System.getenv('AWS_SECRET_ACCESS_KEY')}"
sessionToken "${System.getenv('AWS_SESSION_TOKEN')}"
}
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion cordformation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ext {
repositories {
mavenCentral()
maven {
url "$artifactory_contextUrl/corda-dependencies"
url "$publicArtifactURL/corda-dependencies"
}
}

Expand Down
2 changes: 1 addition & 1 deletion cordformation/src/test/resources/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ docker_image_name=corda/corda-zulu-4.8

slf4j_version=1.7.32

artifactory_contextUrl=https://software.r3.com/artifactory
publicArtifactURL=https://download.corda.net/maven
4 changes: 2 additions & 2 deletions cordformation/src/test/resources/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ dependencyResolutionManagement {
repositories {
mavenCentral()
maven {
url "${artifactory_contextUrl}/corda-releases"
url "${publicArtifactURL}/corda-releases"
}
maven {
url "${artifactory_contextUrl}/corda-dependencies"
url "${publicArtifactURL}/corda-dependencies"
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ artifactory_version=4.21.0
gradle_publish_version=0.21.0

artifactory_contextUrl=https://software.r3.com/artifactory
publicArtifactURL=https://download.corda.net/maven
2 changes: 1 addition & 1 deletion quasar-utils/src/test/resources/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
org.gradle.jvmargs=-XX:+UseG1GC -Xmx512m
org.gradle.caching=false

artifactory_contextUrl=https://software.r3.com/artifactory
publicArtifactURL=https://download.corda.net/maven
2 changes: 1 addition & 1 deletion quasar-utils/src/test/resources/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencyResolutionManagement {
repositories {
mavenCentral()
maven {
url "${artifactory_contextUrl}/corda-dependencies"
url "${publicArtifactURL}/corda-dependencies"
}
}
}

0 comments on commit cce1f4a

Please sign in to comment.