in dsl/scripts/pr_check.groovy [62:121]
void launchStages() {
stage('Initialize') {
sh 'printenv > env_props'
archiveArtifacts artifacts: 'env_props'
}
stage('Install build-chain tool') {
println '[INFO] Getting build-chain version from composite action file'
def buildChainVersion = buildChain.getBuildChainVersionFromCompositeActionFile()
if ([null, 'null'].contains(buildChainVersion)) {
def errorMessage = "[ERROR] The build-chain version can't be recovered. Please contact administrator"
println errorMessage
error(errorMessage)
}
println "[INFO] build-chain version recovered '${buildChainVersion}'"
sh "npm install -g @kie/build-chain-action@${buildChainVersion}${env.NPM_REGISTRY_URL ? " -registry=${NPM_REGISTRY_URL}" : ''}"
sh 'npm list -g | grep build-chain'
sh 'sudo alternatives --install /usr/local/bin/build-chain build-chain ${NODE_HOME}/bin/build-chain 1'
sh 'build-chain || true'
}
stage('Build projects') {
configFileProvider([configFile(fileId: 'kie-pr-settings', variable: 'MAVEN_SETTINGS_FILE')]) { // TODO as env ?
withCredentials([string(credentialsId: 'kie-ci3-token', variable: 'GITHUB_TOKEN')]) { // TODO as env ?
env.BUILD_MVN_OPTS = "${env.BUILD_MVN_OPTS ?: ''} -s ${MAVEN_SETTINGS_FILE} -Dmaven.wagon.http.ssl.insecure=true -Dmaven.test.failure.ignore=true"
echo "BUILD_MVN_OPTS = ${BUILD_MVN_OPTS}"
try {
sh getBuildChainCommandline()
} catch (err) {
echo 'Error running the build-chain ...'
util.archiveConsoleLog('', 300)
throw err
} finally {
// Remove `node_modules` to avoid heap space issues with junit command thereafter
// Related to https://github.com/jenkinsci/junit-plugin/issues/478 and https://github.com/jenkinsci/junit-plugin/issues/467
sh 'find . -type d -name node_modules -exec rm -rf {} \\; || true'
junit(testResults: '**/junit.xml, **/target/surefire-reports/**/*.xml, **/target/failsafe-reports/**/*.xml, **/target/invoker-reports/**/*.xml', allowEmptyResults: true)
archiveArtifacts(artifacts: '**/cypress/screenshots/**,**/cypress/videos/**', fingerprint: false, allowEmptyArchive: true)
}
}
}
}
stage('Sonar analysis') {
if (isEnableSonarCloudAnalysis()) {
dir(getProjectFolder()) {
configFileProvider([configFile(fileId: 'kie-pr-settings', variable: 'MAVEN_SETTINGS_FILE')]) {
withCredentials([string(credentialsId: 'SONARCLOUD_TOKEN', variable: 'TOKEN')]) {
new MavenCommand(this)
.withProperty('sonar.login', "${TOKEN}")
.withProperty('sonar.organization', 'apache') // override what's in pom.xml for now
.withProperty('sonar.projectKey', env.SONAR_PROJECT_KEY)
.withLogFileName('sonar_analysis.maven.log')
.withSettingsXmlFile(MAVEN_SETTINGS_FILE)
.run("-e -nsu validate -Psonarcloud-analysis -Denforcer.skip=true ${env.SONARCLOUD_ANALYSIS_MVN_OPTS ?: ''}")
}
}
}
}
}
}