Skip to content

Commit

Permalink
fix build-chain (#798) (#807)
Browse files Browse the repository at this point in the history
* fix build-chain

* updated build chain args

* removed equal to

* Update build-chain jenkinsfile for v3 (#1)

---------

Co-authored-by: Shubh Bapna <[email protected]>
Co-authored-by: Tristan Radisson <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2023
1 parent a6c2a83 commit 5a5b91d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .ci/actions/build-chain/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ inputs:
required: false
default: 'https://raw.githubusercontent.com/${GROUP:kiegroup}/kogito-pipelines/${BRANCH:main}/.ci/pull-request-config.yaml'
flow-type:
description: "the flow to execute, it can be 'pull-request', 'full-downstream', 'single' or 'branch'"
default: "pull-request"
description: "the flow to execute, it can be 'cross_pr' (or 'pull-request' which is deprecated), 'full_downstream' (or 'full-downstream' which is deprecated), 'single_pr' (or 'single' which is deprecated) or 'branch'"
default: "cross_pr"
required: false
starting-project:
description: "the project to start flow from. By default is the project triggering the job"
Expand All @@ -33,7 +33,7 @@ runs:
steps:
- name: Build Chain Tool Execution
id: build-chain
uses: kiegroup/github-action-build-chain@v2.6.25
uses: kiegroup/github-action-build-chain@v3
with:
definition-file: ${{ inputs.definition-file }}
flow-type: ${{ inputs.flow-type }}
Expand Down
31 changes: 19 additions & 12 deletions .ci/jenkins/Jenkinsfile.buildchain
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mavenDeployRepository = env.MAVEN_DEPLOY_REPOSITORY ?: ''
mavenDeployRepositoryCredsId = env.MAVEN_DEPLOY_REPOSITORY_CREDS_ID ?: ''
mavenDeployLocalDir = env.MAVEN_DEPLOY_LOCAL_DIR ?: ''

buildChainType = env.BUILDCHAIN_TYPE?.trim() ?: 'pr'
buildChainType = env.BUILDCHAIN_TYPE?.trim() ?: 'cross_pr'
buildChainProject = env.BUILDCHAIN_PROJECT?.trim()
defaultSettingsXmlId = isPRBuildChainType() || isFDBBuildChainType() ? 'kogito_pr_settings' : 'kogito_release_settings'
settingsXmlId = env.MAVEN_SETTINGS_FILE_ID ?: defaultSettingsXmlId
Expand All @@ -28,13 +28,13 @@ buildChainConfigRepo = env.BUILDCHAIN_CONFIG_REPO ?: 'kogito-pipelines'
buildChainConfigBranch = env.BUILDCHAIN_CONFIG_BRANCH ?: '\${BRANCH:main}'
buildChainConfigGitAuthor = env.BUILDCHAIN_CONFIG_AUTHOR ?: '\${AUTHOR:kiegroup}'
buildChainConfigDefinitionFilePath = env.BUILDCHAIN_CONFIG_FILE_PATH ?: '.ci/pull-request-config.yaml'
buildChainAction = isFDBBuildChainType() ? 'fd' : buildChainType
buildChainAdditionalArguments = buildChainProject ? [ "-sp=${buildChainProject}" ] : []
buildChainAction = isFDBBuildChainType() ? 'full_downstream' : buildChainType
buildChainAdditionalArguments = buildChainProject ? [ "-p ${buildChainProject}" ] : []
if (isBranchBuildChainType()) {
buildChainAdditionalArguments.add("-b=${env.GIT_BRANCH_NAME.trim()}")
buildChainAdditionalArguments.add("-g=${env.GIT_AUTHOR.trim()}")
buildChainAdditionalArguments.add("-b ${env.GIT_BRANCH_NAME.trim()}")
buildChainAdditionalArguments.add("-g ${env.GIT_AUTHOR.trim()}")
} else {
buildChainAdditionalArguments.add("-url=${env.ghprbPullLink}")
buildChainAdditionalArguments.add("-u ${env.ghprbPullLink}")
}

skipTests = params.SKIP_TESTS ?: false
Expand Down Expand Up @@ -94,6 +94,8 @@ pipeline {
}
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"
}
}
}
Expand Down Expand Up @@ -185,9 +187,14 @@ pipeline {
steps {
script {
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}") {

// First guessing whether there is a clone defined into the buildchain config
// If not, fallback to simple folder structure
String projectFolder = "bc/kiegroup_${project}/${project}"
if (!fileExists(projectFolder)) {
projectFolder = "bc/kiegroup_${project}"
}
dir(projectFolder) {
maven.runMavenWithSettingsSonar(settingsXmlId, "-e -nsu validate -Psonarcloud-analysis -Denforcer.skip=true ${env.SONARCLOUD_ANALYSIS_MVN_OPTS ?: ''}", 'SONARCLOUD_TOKEN', 'sonar_analysis.maven.log')
}
}
Expand Down Expand Up @@ -239,11 +246,11 @@ pipeline {
}

boolean isPRBuildChainType() {
return buildChainType == 'pr'
return buildChainType == 'cross_pr'
}

boolean isFDBBuildChainType() {
return buildChainType == 'fdb'
return buildChainType == 'full_downstream'
}

boolean isSingleBuildChainType() {
Expand Down Expand Up @@ -279,7 +286,7 @@ boolean shouldNotify() {
}

String getBuildChainCommandline(boolean includeToken=false) {
return "build-chain-action ${includeToken ? "-token=${GITHUB_TOKEN} " : ''}-df='https://raw.githubusercontent.com/${buildChainConfigGitAuthor}/${buildChainConfigRepo}/${buildChainConfigBranch}/${buildChainConfigDefinitionFilePath}' -folder='bc' build ${buildChainAction} ${buildChainAdditionalArguments.join(' ')} --skipParallelCheckout"
return "build-chain build ${buildChainAction} ${includeToken ? "--token ${GITHUB_TOKEN} " : ''}-f 'https://raw.githubusercontent.com/${buildChainConfigGitAuthor}/${buildChainConfigRepo}/${buildChainConfigBranch}/${buildChainConfigDefinitionFilePath}' -o 'bc' ${buildChainAdditionalArguments.join(' ')} --skipParallelCheckout"
}

String getReproducer() {
Expand Down
5 changes: 2 additions & 3 deletions .ci/pull-request-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ build:
# Then build the required submodule pom
current: |
export MVN_CMD=`bash -c "if [ '${{ env.ENABLE_DEPLOY }}' = 'true' ]; then printf 'deploy ${{ env.DEPLOY_MVN_OPTS }} ${{ env.KOGITO_EXAMPLES_DEPLOY_MVN_OPTS }}'; else printf 'install'; fi"`
mvn -f kogito-examples/pom.xml -pl :kogito-examples clean ${{ env.MVN_CMD }} ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }}
mvn -f kogito-examples/${{ env.KOGITO_EXAMPLES_SUBFOLDER_POM }}pom.xml clean ${{ env.MVN_CMD }} -Dvalidate-formatting ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }}
mvn -pl :kogito-examples clean ${{ env.MVN_CMD }} ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }}
mvn -f ${{ env.KOGITO_EXAMPLES_SUBFOLDER_POM }}pom.xml clean ${{ env.MVN_CMD }} ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_CURRENT }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS }}
upstream: |
mvn clean install -Dquickly ${{ env.BUILD_MVN_OPTS }} ${{ env.BUILD_MVN_OPTS_UPSTREAM }} ${{ env.KOGITO_EXAMPLES_BUILD_MVN_OPTS_UPSTREAM }}
clone:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,7 @@ class KogitoJobTemplate {
if (useBuildChain) {
// Buildchain uses centralized configuration for Jenkinsfile.buildchain to checkout
// Overrides configuration already done
String buildChainCheckoutBranch = Utils.getSeedBranch(script)
jobParams.pr.checkout_branch = buildChainCheckoutBranch
jobParams.git.author = Utils.getSeedAuthor(script)
jobParams.env.put('BUILDCHAIN_PROJECT', "kiegroup/${jobCfg.repository ?: jobParams.git.repository}")
jobParams.env.put('BUILDCHAIN_TYPE', 'pr')
jobParams.env.put('BUILDCHAIN_CONFIG_REPO', Utils.getBuildChainConfigRepo(script) ?: Utils.getSeedRepo(script))
jobParams.env.put('BUILDCHAIN_CONFIG_AUTHOR', Utils.getBuildChainConfigAuthor(script) ?: Utils.getSeedAuthor(script))
jobParams.env.put('BUILDCHAIN_CONFIG_BRANCH', Utils.getBuildChainConfigBranch(script) ?: buildChainCheckoutBranch)
jobParams.env.put('BUILDCHAIN_CONFIG_FILE_PATH', Utils.getBuildChainConfigFilePath(script))
jobParams.env.put('NOTIFICATION_JOB_NAME', "(${testTypeId}) - ${jobCfg.id}")
jobParams.git.repository = Utils.getSeedRepo(script)
jobParams.jenkinsfile = Utils.getSeedJenkinsfilePath(script, KogitoConstants.BUILD_CHAIN_JENKINSFILE)
JobParamsUtils.setupJobParamsBuildChainConfiguration(script, jobParams, jobCfg.repository ?: jobParams.git.repository, 'cross_pr', "(${testTypeId}) - ${jobCfg.id}")

// Status messages are sent directly by the pipeline as comments
jobParams.pr.putAll([
Expand Down

0 comments on commit 5a5b91d

Please sign in to comment.