Skip to content

Commit

Permalink
Split nightly jobs for more flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste committed Apr 29, 2022
1 parent 468d45e commit f121e69
Show file tree
Hide file tree
Showing 40 changed files with 3,213 additions and 1,066 deletions.
47 changes: 32 additions & 15 deletions .ci/jenkins/Jenkinsfile.buildchain
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ 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
downstreamBuild = env.DOWNSTREAM_BUILD ? env.DOWNSTREAM_BUILD.toBoolean() : false
Expand All @@ -16,10 +16,21 @@ 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/kiegroup/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 @@ -106,7 +117,7 @@ pipeline {
}
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,23 +151,23 @@ 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 isBranchBuildChainType() {
return buildChainType == 'branch'
}

boolean isSonarCloudAnalysis() {
if (disableSonarCloudAnalysis) {
return false
}
if (isPR()) {
if (isPRBuildChainType()) {
return !downstreamBuild
}
return false
Expand All @@ -167,5 +178,11 @@ String getBuildMavenOptsCurrent() {
isSonarCloudAnalysis() ? 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

0 comments on commit f121e69

Please sign in to comment.