Skip to content

Commit

Permalink
kie-issues#574 Initial ASF Jenkins CI Setup (apache#607)
Browse files Browse the repository at this point in the history
Co-authored-by: jstastny-cz <[email protected]>
  • Loading branch information
2 people authored and lucamolteni committed Jul 26, 2024
1 parent ffc95fb commit 21c2673
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .ci/environments/common/update_quarkus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

mvn_cmd="mvn ${BUILD_MVN_OPTS:-} ${BUILD_MVN_OPTS_QUARKUS_UPDATE:-}"

source <(curl -s https://raw.githubusercontent.com/kiegroup/kogito-pipelines/main/dsl/seed/scripts/install_quarkus.sh)
source <(curl -s https://raw.githubusercontent.com/apache/incubator-kie-kogito-pipelines/main/dsl/seed/scripts/install_quarkus.sh)

echo "Update project with Quarkus version ${QUARKUS_VERSION}"

Expand Down
43 changes: 43 additions & 0 deletions .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@Library('jenkins-pipeline-shared-libraries')_

pr_check_script = null

pipeline {
agent {
label 'ubuntu'
}
options {
timestamps()
timeout(time: 720, unit: 'MINUTES')
}
environment {
BUILDCHAIN_PROJECT = 'apache/incubator-kie-optaplanner-quickstarts'
BUILDCHAIN_CONFIG_REPO = 'apache/incubator-kie-optaplanner'
BUILDCHAIN_CONFIG_FILE_PATH = '.ci/buildchain-config.yaml'

OPTAPLANNER_BUILD_MVN_OPTS_UPSTREAM = '-Dfull'
BUILD_MVN_OPTS_CURRENT = '-Dfull'
}
stages {
stage('Initialize') {
steps {
script {
// load `pr_check.groovy` file from kogito-pipelines:main
dir('kogito-pipelines') {
checkout(githubscm.resolveRepository('incubator-kie-kogito-pipelines', 'apache', 'main', false, 'kie-ci')) // TODO to change back to kiegroup:main
pr_check_script = load 'dsl/scripts/pr_check.groovy'
}
}
}
}
stage('PR check') {
steps {
script {
dir('kogito-pipelines') {
pr_check_script.launch()
}
}
}
}
}
}
36 changes: 13 additions & 23 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,27 @@ import org.jenkinsci.plugins.workflow.libs.Library

import org.kie.jenkins.MavenCommand

optaplannerRepo = 'optaplanner'
optaplannerRepo = 'incubator-kie-optaplanner'

pipeline {
agent {
label util.avoidFaultyNodes('kie-rhel8 && !built-in')
label 'ubuntu'
}

tools {
maven env.BUILD_MAVEN_TOOL
jdk env.BUILD_JDK_TOOL
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}

options {
timestamps()
timeout(time: 60, unit: 'MINUTES')
}

// parameters {
// For parameters, check into ./dsl/jobs.groovy file
// }

environment {
// Static env is defined into ./dsl/jobs.groovy file

OPTAPLANNER_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

// Keep here for visitibility
MAVEN_OPTS = '-Xms1024m -Xmx4g'
}

stages {
Expand All @@ -43,7 +36,8 @@ pipeline {
currentBuild.displayName = params.DISPLAY_NAME
}

checkoutRepo(optaplannerRepo, getBuildBranch())
optaplannerBranch = getBuildBranch() == 'development' ? '9.x' : getBuildBranch() == '8.x' ? 'main' : getBuildBranch()
checkoutRepo(optaplannerRepo, optaplannerBranch)
checkoutRepo(getRepoName(), getBuildBranch())
}
}
Expand Down Expand Up @@ -75,12 +69,12 @@ pipeline {
dir(getRepoName()) {
if (githubscm.isThereAnyChanges()) {
def commitMsg = "Update version to ${getOptaPlannerVersion()}"
githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())

githubscm.commitChanges(commitMsg, {
githubscm.findAndStageNotIgnoredFiles('pom.xml')
githubscm.findAndStageNotIgnoredFiles('build.gradle')
})
githubscm.pushObject('origin', getBuildBranch(), getGitAuthorPushCredsId())
githubscm.pushObject('origin', getBuildBranch(), getGitAuthorCredsID())
} else {
println '[WARN] no changes to commit'
}
Expand Down Expand Up @@ -113,7 +107,7 @@ void sendErrorNotification() {
void checkoutRepo(String repository, String branch) {
dir(repository) {
deleteDir()
checkout(githubscm.resolveRepository(repository, getGitAuthor(), branch, false, getGitAuthorCredsId()))
checkout(githubscm.resolveRepository(repository, getGitAuthor(), branch, false))
// need to manually checkout branch since on a detached branch after checkout command
sh "git checkout ${branch}"
}
Expand All @@ -136,12 +130,8 @@ String getOptaPlannerVersion() {
return params.OPTAPLANNER_VERSION
}

String getGitAuthorCredsId() {
return env.GIT_AUTHOR_CREDS_ID
}

String getGitAuthorPushCredsId() {
return env.GIT_AUTHOR_PUSH_CREDS_ID
String getGitAuthorCredsID() {
return env.AUTHOR_CREDS_ID
}

MavenCommand getMavenCommand(String directory) {
Expand Down
9 changes: 4 additions & 5 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This file is describing all the Jenkins jobs in the DSL format (see https://plugins.jenkins.io/job-dsl/)
* needed by the Kogito pipelines.
*
* The main part of Jenkins job generation is defined into the https://github.com/kiegroup/kogito-pipelines repository.
* The main part of Jenkins job generation is defined into the https://github.com/apache/incubator-kie-kogito-pipelines repository.
*
* This file is making use of shared libraries defined in
* https://github.com/kiegroup/kogito-pipelines/tree/main/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl.
* https://github.com/apache/incubator-kie-kogito-pipelines/tree/main/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl.
*/

import org.kie.jenkins.jobdsl.model.JobType
Expand Down Expand Up @@ -35,7 +35,7 @@ Map getMultijobPRConfig() {
}

// Optaplanner PR checks
KogitoJobUtils.createAllEnvironmentsPerRepoPRJobs(this) { jobFolder -> getMultijobPRConfig() }
Utils.isMainBranch(this) && KogitoJobTemplate.createPullRequestMultibranchPipelineJob(this, "${jenkins_path}/Jenkinsfile")

// Init branch
createSetupBranchJob()
Expand All @@ -62,9 +62,8 @@ void setupSpecificBuildChainNightlyJob(String envName) {

void createSetupBranchJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'optaplanner-quickstarts', JobType.SETUP_BRANCH, "${jenkins_path}/Jenkinsfile.setup-branch", 'OptaPlanner Quickstarts Setup Branch')
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
REPO_NAME: 'optaplanner-quickstarts',
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",

GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
Expand Down
8 changes: 4 additions & 4 deletions .ci/jenkins/dsl/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ fi

git_author="$(echo ${git_url} | awk -F"${git_server_url}" '{print $2}' | awk -F. '{print $1}' | awk -F/ '{print $1}')"

export DSL_DEFAULT_MAIN_CONFIG_FILE_REPO="${git_author}"/optaplanner
export DSL_DEFAULT_FALLBACK_MAIN_CONFIG_FILE_REPO=kiegroup/optaplanner
export DSL_DEFAULT_MAIN_CONFIG_FILE_REPO="${git_author}"/incubator-kie-optaplanner
export DSL_DEFAULT_FALLBACK_MAIN_CONFIG_FILE_REPO=apache/incubator-kie-optaplanner
export DSL_DEFAULT_MAIN_CONFIG_FILE_PATH=.ci/jenkins/config/main.yaml
export DSL_DEFAULT_BRANCH_CONFIG_FILE_REPO="${git_author}"/optaplanner
export DSL_DEFAULT_BRANCH_CONFIG_FILE_REPO="${git_author}"/incubator-kie-optaplanner

file=$(mktemp)
# For more usage of the script, use ./test.sh -h
curl -o ${file} https://raw.githubusercontent.com/kiegroup/kogito-pipelines/main/dsl/seed/scripts/seed_test.sh
curl -o ${file} https://raw.githubusercontent.com/apache/incubator-kie-kogito-pipelines/main/dsl/seed/scripts/seed_test.sh
chmod u+x ${file}
${file} $@
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ and also the external https://github.com/quarkusio/quarkus-quickstarts/tree/main
### Referenced pull requests

<!-- Add URLs of all referenced pull requests if they exist. This is only required when making
changes that span multiple kiegroup repositories and depend on each other. -->
changes that span multiple KIE repositories and depend on each other. -->
<!-- Example:
- https://github.com/kiegroup/droolsjbpm-build-bootstrap/pull/1234
- https://github.com/kiegroup/drools/pull/3000
- https://github.com/kiegroup/optaplanner/pull/899
- https://github.com/apache/incubator-kie-drools/pull/3000
- https://github.com/apache/incubator-kie-optaplanner/pull/899
- etc.
-->

Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/full-downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ jobs:
restore-keys: ${{ runner.os }}-${{ matrix.java-version }}-m2
- name: Build Chain ${{ matrix.java-version }}
id: build-chain
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/build-chain@main
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/github-action-build-chain@v3.1.10
with:
definition-file: https://raw.githubusercontent.com/${GROUP:apache}/incubator-kie-optaplanner/${BRANCH:main}/.ci/buildchain-config.yaml
definition-file: https://raw.githubusercontent.com/${GROUP}/incubator-kie-optaplanner/main/.ci/buildchain-config.yaml
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
OPTAPLANNER_BUILD_MVN_OPTS_UPSTREAM: "-Dfull"
- name: Surefire Report
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/surefire-report@main
- name: Check Surefire Report
if: ${{ always() }}
uses: ScaCap/[email protected]
with:
fail_on_test_failures: true
fail_if_no_tests: false
skip_publishing: true
6 changes: 0 additions & 6 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ jobs:
- name: Support long paths
if: ${{ matrix.os == 'windows-latest' }}
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/long-paths@main
- name: Sets the migration env variable on Windows
if: runner.os == 'Windows'
run: echo "MIGRATE_TO_9=${{ github.base_ref == 'development' }}" >> $env:GITHUB_ENV
- name: Sets the migration env variable on Linux
if: runner.os != 'Windows'
run: echo "MIGRATE_TO_9=${{ github.base_ref == 'development' }}" >> $GITHUB_ENV
- name: Java and Maven Setup
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/maven@main
with:
Expand Down

0 comments on commit 21c2673

Please sign in to comment.