Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ withPipeline(type, product, component) {
// hmcts/cnp-jenkins-library may fail to copy artifacts after checkstyle error so repeat command (see /src/uk/gov/hmcts/contino/GradleBuilder.groovy)

builder.gradle('integration')
builder.gradle('jacocoTestReport')
builder.gradle('sonar')

steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/reports/checkstyle/*.html'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/reports/pmd/*.html'
archiveSonarArtifacts()

copyIgnore('./build/reports/tests/integration', './Integration Tests/')
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Integration Tests/**/*'
Expand Down Expand Up @@ -251,3 +254,26 @@ withPipeline(type, product, component) {
def copyIgnore(filePath, destinationDir) {
steps.sh("cp -R '${filePath}' '${destinationDir}' || :")
}

def archiveSonarArtifacts() {
def sonarTaskReport = 'build/sonar/report-task.txt'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/sonar/**,.scannerwork/report-task.txt'

if (steps.fileExists(sonarTaskReport)) {
def dashboardLine = steps.readFile(sonarTaskReport).readLines().find { it.startsWith('dashboardUrl=') }
if (dashboardLine) {
steps.echo "SonarQube dashboard: ${dashboardLine.substring('dashboardUrl='.length())}"
} else {
steps.echo "Sonar report task file archived but dashboardUrl is missing in ${sonarTaskReport}"
}
} else if (steps.fileExists('.scannerwork/report-task.txt')) {
def dashboardLine = steps.readFile('.scannerwork/report-task.txt').readLines().find { it.startsWith('dashboardUrl=') }
if (dashboardLine) {
steps.echo "SonarQube dashboard: ${dashboardLine.substring('dashboardUrl='.length())}"
} else {
steps.echo "Sonar report task file archived but dashboardUrl is missing in .scannerwork/report-task.txt"
}
} else {
steps.echo 'Sonar task report not found to archive.'
}
}
24 changes: 24 additions & 0 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ withNightlyPipeline(type, product, component) {
afterAlways('test') {
// hmcts/cnp-jenkins-library may fail to copy artifacts after checkstyle error so repeat command (see /src/uk/gov/hmcts/contino/GradleBuilder.groovy)
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/reports/checkstyle/*.html'
archiveSonarArtifacts()
}

enableFullFunctionalTest(200)
Expand All @@ -278,3 +279,26 @@ withNightlyPipeline(type, product, component) {
}
enableSlackNotifications('#ccd-nightly-builds')
}

def archiveSonarArtifacts() {
def sonarTaskReport = 'build/sonar/report-task.txt'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/sonar/**,.scannerwork/report-task.txt'

if (steps.fileExists(sonarTaskReport)) {
def dashboardLine = steps.readFile(sonarTaskReport).readLines().find { it.startsWith('dashboardUrl=') }
if (dashboardLine) {
steps.echo "SonarQube dashboard: ${dashboardLine.substring('dashboardUrl='.length())}"
} else {
steps.echo "Sonar report task file archived but dashboardUrl is missing in ${sonarTaskReport}"
}
} else if (steps.fileExists('.scannerwork/report-task.txt')) {
def dashboardLine = steps.readFile('.scannerwork/report-task.txt').readLines().find { it.startsWith('dashboardUrl=') }
if (dashboardLine) {
steps.echo "SonarQube dashboard: ${dashboardLine.substring('dashboardUrl='.length())}"
} else {
steps.echo "Sonar report task file archived but dashboardUrl is missing in .scannerwork/report-task.txt"
}
} else {
steps.echo 'Sonar task report not found to archive.'
}
}
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,21 @@ jsonSchema2Pojo {

sonarqube {
properties {
def sonarProjectKey = System.getenv("SONAR_PROJECT_KEY") ?: "ccd-data-store-api"
def sonarOrganization = System.getenv("SONAR_ORGANIZATION") ?: "hmcts"
def sonarToken = System.getenv("SONAR_TOKEN") ?: System.getenv("SONAR_AUTH_TOKEN")

property "sonar.exclusions", "build/generated-sources/**/*.java," +
"**/AppInsightsConfiguration.java," +
"**/TestingSupportController.java"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.projectName", "ccd-data-store-api"
property "sonar.projectKey", "ccd-data-store-api"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.outputLocation}"
property "sonar.projectKey", sonarProjectKey
property "sonar.organization", sonarOrganization
if (sonarToken) {
property "sonar.token", sonarToken
}
property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
}

Expand Down