Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split nightly jobs #283

Closed
wants to merge 2 commits into from
Closed
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
61 changes: 34 additions & 27 deletions .ci/jenkins/Jenkinsfile.buildchain
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@ timeoutValue = env.ADDITIONAL_TIMEOUT?.trim() ?: '180'
jdkTool = env.BUILD_JDK_TOOL?.trim() ?: 'kie-jdk11'
mavenTool = env.BUILD_MAVEN_TOOL?.trim() ?: 'kie-maven-3.8.1'

prType = env.BUILDCHAIN_PR_TYPE?.trim() ?: 'pr'
buildChainType = env.BUILDCHAIN_PR_TYPE?.trim() ?: 'pr'
buildChainProject = env.BUILDCHAIN_PROJECT?.trim()
settingsXmlId = isPR() || isFDB() ? 'kogito_pr_settings' : 'kogito_release_settings'
settingsXmlId = isPRBuildChainType() || isFDBBuildChainType() ? 'kogito_pr_settings' : 'kogito_release_settings'

disableSonarCloudAnalysis = env.DISABLE_SONARCLOUD ? env.DISABLE_SONARCLOUD.toBoolean() : false
enableSonarCloudAnalysis = env.ENABLE_SONARCLOUD ? env.ENABLE_SONARCLOUD.toBoolean() : false
downstreamBuild = env.DOWNSTREAM_BUILD ? env.DOWNSTREAM_BUILD.toBoolean() : false
native_build = env.NATIVE ? env.NATIVE.toBoolean() : false
native_builder_image = env.NATIVE_BUILDER_IMAGE ?: ''

buildChainConfigBranch = env.BUILDCHAIN_CONFIG_BRANCH ?: '\${BRANCH:main}'
buildChainDefinitionFile = env.QUARKUS_BRANCH ? 'pull-request-quarkus-config.yaml' : 'pull-request-config.yaml'
buildChainAction = isFDB() ? 'fd' : prType
buildChainAdditionalArguments = buildChainProject ? "-sp=${buildChainProject}" : ''
buildChainAction = isFDBBuildChainType() ? 'fd' : buildChainType
buildChainAdditionalArguments = buildChainProject ? ["-sp=${buildChainProject}"] : []
if (isBranchBuildChainType()) {
buildChainAdditionalArguments.add("-p=${buildChainProject.trim()}")
buildChainAdditionalArguments.add("-b=${env.GIT_BRANCH_NAME.trim()}")
buildChainAdditionalArguments.add("-g=${env.GIT_AUTHOR.trim()}")
} else {
buildChainAdditionalArguments.add("-url=${env.ghprbPullLink}")
}

notificationJobName = env.NOTIFICATION_JOB_NAME ?: 'PR'
skipTests = params.SKIP_TESTS ?: false
skipIntegrationTests = params.SKIP_IT_TESTS ?: false
native_build = env.NATIVE ? env.NATIVE.toBoolean() : false
native_builder_image = env.NATIVE_BUILDER_IMAGE ?: ''

pipeline {
agent {
Expand Down Expand Up @@ -79,14 +90,14 @@ pipeline {

configFileProvider([configFile(fileId: settingsXmlId, variable: 'MAVEN_SETTINGS_FILE')]) {
withCredentials([string(credentialsId: 'kie-ci1-token', variable: 'GITHUB_TOKEN')]) {
sh "build-chain-action -token=${GITHUB_TOKEN} -df='https://raw.githubusercontent.com/kiegroup/kogito-pipelines/${buildChainConfigBranch}/.ci/${buildChainDefinitionFile}' -folder='bc' build ${buildChainAction} -url=${env.ghprbPullLink} ${buildChainAdditionalArguments} --skipParallelCheckout -cct '(^mvn .*)||\$1 -s ${MAVEN_SETTINGS_FILE} -Dmaven.wagon.http.ssl.insecure=true -Dmaven.test.failure.ignore=true'"
sh "build-chain-action -token=${GITHUB_TOKEN} -df='https://raw.githubusercontent.com/radtriste/kogito-pipelines/${buildChainConfigBranch}/.ci/${buildChainDefinitionFile}' -folder='bc' build ${buildChainAction} ${buildChainAdditionalArguments.join(' ')} --skipParallelCheckout -cct '(^mvn .*)||\$1 -s ${MAVEN_SETTINGS_FILE} -Dmaven.wagon.http.ssl.insecure=true -Dmaven.test.failure.ignore=true'"
}
}
}
}
post {
always {
junit '**/target/surefire-reports/**/*.xml, **/target/failsafe-reports/**/*.xml'
junit(testResults: '**/target/surefire-reports/**/*.xml,**/target/failsafe-reports/**/*.xml', allowEmptyResults: (skipTests || skipIntegrationTests))
archiveArtifacts(artifacts: '**/cypress/screenshots/**,**/cypress/videos/**', fingerprint: false, allowEmptyArchive: true)
}
unsuccessful {
Expand All @@ -98,15 +109,15 @@ pipeline {
}
stage('Sonar analysis') {
when {
expression { return isSonarCloudAnalysis() }
expression { return enableSonarCloudAnalysis }
}
tools {
jdk jdkTool
maven mavenTool
}
steps {
script {
def project = (env.BUILDCHAIN_PROJECT ? util.getProjectGroupName(env.BUILDCHAIN_PROJECT) : util.getProjectTriggeringJob())[1]
def project = (buildChainProject ? util.getProjectGroupName(buildChainProject) : util.getProjectTriggeringJob())[1]
// Project should define a `clone` for the current command so that the pom can be found for sonarcloud analysis
// Else this next step will fail
dir("bc/kiegroup_${project.replaceAll('-', '_')}/${project}") {
Expand All @@ -126,7 +137,7 @@ pipeline {
post {
unsuccessful {
script {
if (isPR()) {
if (shouldNotify()) {
pullrequest.postComment(util.getMarkdownTestSummary(notificationJobName, '', "${BUILD_URL}", 'GITHUB'))
}
}
Expand All @@ -140,32 +151,28 @@ pipeline {
}
}

boolean isPR() {
return prType == 'pr'
boolean isPRBuildChainType() {
return buildChainType == 'pr'
}

boolean isFDB() {
return prType == 'fdb'
boolean isFDBBuildChainType() {
return buildChainType == 'fdb'
}

boolean isSingle() {
return prType == 'single'
}

boolean isSonarCloudAnalysis() {
if (disableSonarCloudAnalysis) {
return false
}
if (isPR()) {
return !downstreamBuild
}
return false
boolean isBranchBuildChainType() {
return buildChainType == 'branch'
}

String getBuildMavenOptsCurrent() {
List opts_current = env.BUILD_MVN_OPTS_CURRENT ? [ env.BUILD_MVN_OPTS_CURRENT ] : []
isSonarCloudAnalysis() ? opts_current.add('-Prun-code-coverage') : null
enableSonarCloudAnalysis ? opts_current.add('-Prun-code-coverage') : null
native_build ? opts_current.add('-Dquarkus.native.container-build=true -Dnative -Pnative') : null
native_builder_image ? opts_current.add("-Dquarkus.native.builder-image=${native_builder_image}") : null
skipTests ? opts_current.add('-DskipTests') : null
skipIntegrationTests ? opts_current.add('-DskipITs') : null
return opts_current.join(' ')
}

boolean shouldNotify() {
return !isBranchBuildChainType()
}
Loading