diff --git a/.ci/dev/nightly-regression/JenkinsfileSnykScan b/.ci/dev/nightly-regression/JenkinsfileSnykScan new file mode 100644 index 0000000000..564bb516a9 --- /dev/null +++ b/.ci/dev/nightly-regression/JenkinsfileSnykScan @@ -0,0 +1,7 @@ +@Library('corda-shared-build-pipeline-steps') _ + +cordaSnykScanPipeline ( + snykTokenId: 'c4-os-snyk-api-token-secret', + // specify the Gradle submodules to scan and monitor on snyk Server + modulesToScan: ['node', 'capsule', 'bridge', 'bridgecapsule'] +) diff --git a/.ci/dev/regression/Jenkinsfile b/.ci/dev/regression/Jenkinsfile index 39aeaf4ad8..1ce7245e68 100644 --- a/.ci/dev/regression/Jenkinsfile +++ b/.ci/dev/regression/Jenkinsfile @@ -5,6 +5,10 @@ */ @Library('corda-shared-build-pipeline-steps') +import com.r3.build.utils.GitUtils + +GitUtils gitUtils = new GitUtils(this) + /** * Sense environment */ @@ -14,34 +18,6 @@ boolean isInternalRelease = (env.TAG_NAME =~ /^internal-release-.*$/) boolean isReleaseCandidate = (env.TAG_NAME =~ /^(release-.*(RC|HC).*(?version-properties" - /* every build related to Corda X.Y (GA, RC, HC, patch or snapshot) uses the same NexusIQ application */ - def version = sh (returnStdout: true, script: "grep ^version: version-properties | sed -e 's/^version: \\([0-9]\\+\\(\\.[0-9]\\+\\)\\+\\).*\$/\\1/'").trim() - def groupId = sh (returnStdout: true, script: "grep ^group: version-properties | sed -e 's/^group: //'").trim() - def artifactId = 'corda' - nexusAppId = "${groupId}-${artifactId}-${version}" - } - nexusPolicyEvaluation ( - failBuildOnNetworkError: false, - iqApplication: selectedApplication(nexusAppId), // application *has* to exist before a build starts! - iqScanPatterns: [[scanPattern: 'node/capsule/build/libs/corda*.jar']], - iqStage: params.nexusIqStage - ) - } - } - stage('Generate Wiki Report') { - when { - expression { isReleaseTag && !isInternalRelease && !isReleaseCandidate } - beforeAgent true - } - agent { - docker { - image 'nexusiq-sonatype-cli:latest' - reuseNode true - registryUrl 'https://engineering-docker.software.r3.com/' - registryCredentialsId 'artifactory-credentials' - } - } - options { - retry(3) - } - environment { - NEXUS_APP_ID="${nexusAppId}" - NEXUS_APP_STAGE="${params.nexusIqStage}" - NEXUSIQ_CREDENTIALS = credentials('jenkins-nexusiq-credentials') - } - steps { - sh '''\ - rm -f wiki-report.md - env NEXUSIQ_USERNAME="${NEXUSIQ_CREDENTIALS_USR}" \ - NEXUSIQ_PASSWORD="${NEXUSIQ_CREDENTIALS_PSW}" \ - /opt/app/wrapper wiki-report \ - --app "${NEXUS_APP_ID}" \ - --stage "${NEXUS_APP_STAGE}" >wiki-report.md - '''.stripIndent() - archiveArtifacts 'wiki-report.md' - } - } - stage('Generate Licence Report') { - when { - expression { isReleaseTag && !isInternalRelease && !isReleaseCandidate } - beforeAgent true - } - agent { - docker { - image 'nexusiq-licence-report:latest' - reuseNode true - registryUrl 'https://engineering-docker.software.r3.com/' - registryCredentialsId 'artifactory-credentials' - } - } - options { - retry(3) - } - environment { - NEXUS_APP_ID="${nexusAppId}" - NEXUS_APP_STAGE="${params.nexusIqStage}" - NEXUSIQ_CREDENTIALS = credentials('jenkins-nexusiq-credentials') - } - steps { - sh '''\ - rm -rf report - env NEXUSIQ_USERNAME="${NEXUSIQ_CREDENTIALS_USR}" \ - NEXUSIQ_PASSWORD="${NEXUSIQ_CREDENTIALS_PSW}" \ - /opt/app/wrapper --write --outdir report \ - --force \ - --app "${NEXUS_APP_ID}" \ - --stage "${NEXUS_APP_STAGE}" - '''.stripIndent() - archiveArtifacts 'report/*.md' - } - } - stage('Snyk Security') { + stage('Snyk Security') { when { expression { isReleaseTag || isReleaseCandidate || isReleaseBranch } } @@ -206,6 +98,22 @@ pipeline { } } + stage('Generate Snyk License Report') { + when { + expression { isReleaseTag || isReleaseCandidate || isReleaseBranch } + } + steps { + snykLicenseGeneration(env.SNYK_API_TOKEN, env.C4_OS_SNYK_ORG_ID) + } + post { + always { + script { + archiveArtifacts artifacts: 'snyk-license-report/*-snyk-license-report.html', allowEmptyArchive: true, fingerprint: true + } + } + } + } + stage('All Tests') { when { expression { params.DO_TEST } @@ -417,6 +325,9 @@ pipeline { post { always { script { + if (gitUtils.isReleaseTag()) { + gitUtils.getGitLog(env.TAG_NAME, env.GIT_URL.replace('https://github.com/corda/', ''), scm.userRemoteConfigs[0].credentialsId) + } try { if (params.DO_TEST) { unstash 'allure-input' @@ -472,20 +383,23 @@ pipeline { } } success { - script { - sendSlackNotifications("good", "BUILD PASSED", false, "#corda-corda4-open-source-build-notifications") + script { + sendSlackNotifications("good", "BUILD PASSED", false, "#corda-corda4-open-source-build-notifications") if (isReleaseTag || isReleaseCandidate || isReleaseBranch) { snykSecurityScan.generateHtmlElements() } - } + } } unstable { - script { - sendSlackNotifications("warning", "BUILD UNSTABLE - Unstable Builds are likely a result of Nexus Sonar Scanner violations", false, "#corda-corda4-open-source-build-notifications") + script { + sendSlackNotifications("warning", "BUILD UNSTABLE", false, "#corda-corda4-open-source-build-notifications") if (isReleaseTag || isReleaseCandidate || isReleaseBranch) { snykSecurityScan.generateHtmlElements() } - } + if (isReleaseTag || isReleaseCandidate || isReleaseBranch) { + snykSecurityScan.generateHtmlElements() + } + } } failure { script {