Skip to content

Commit

Permalink
kie-issues#574 Initial ASF Jenkins CI Setup (#1810)
Browse files Browse the repository at this point in the history
deactivate PR checks

Prepare for Apache migration

Remove PR job

[apache_migration] update pipelines (#1790)

* Setup jenkinsfile

* update pipelines

Fix CI

PR multibranchPipelineJob (#1808)



Update `kiegroup` repository references to `apache` (#1806)

Co-authored-by: radtriste <[email protected]>
Co-authored-by: jstastny-cz <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2023
1 parent 6ac7572 commit a3b3764
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 94 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
2 changes: 1 addition & 1 deletion .ci/environments/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ if [ -f "${env_path}/after.sh" ]; then
fi

# Download `setup_integration_branch` script and execute
curl -s https://raw.githubusercontent.com/kiegroup/kogito-pipelines/main/dsl/seed/scripts/setup_integration_branch.sh | bash
curl -s https://raw.githubusercontent.com/apache/incubator-kie-kogito-pipelines/main/dsl/seed/scripts/setup_integration_branch.sh | bash
40 changes: 40 additions & 0 deletions .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@Library('jenkins-pipeline-shared-libraries')_

pr_check_script = null

pipeline {
agent {
label 'ubuntu'
}
options {
timestamps()
timeout(time: 360, unit: 'MINUTES')
}
environment {
BUILDCHAIN_PROJECT = 'apache/incubator-kie-kogito-examples'

KOGITO_EXAMPLES_BUILD_MVN_OPTS = '-Dvalidate-formatting'
}
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, 'ASF_Cloudbees_Jenkins_ci-builds'))
pr_check_script = load 'dsl/scripts/pr_check.groovy'
}
}
}
}
stage('PR check') {
steps {
script {
dir('kogito-pipelines') {
pr_check_script.launch()
}
}
}
}
}
}
29 changes: 9 additions & 20 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,22 @@ examplesHelper = null

pipeline {
agent {
label 'kie-rhel8 && docker && kie-mem16g && !built-in'
}

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: 180, unit: 'MINUTES')
}

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

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

KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

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

PR_BRANCH_HASH = "${util.generateHash(10)}"
MAVEN_DEPLOY_LOCAL_DIR = "${WORKSPACE}/maven_deploy_dir"
MAVEN_DEPLOY_LOCAL_DIR = "/tmp/maven_deploy_dir"
}

stages {
Expand Down Expand Up @@ -132,7 +121,7 @@ pipeline {
if (params.SKIP_TESTS) {
mvnCmd.skipTests() // Conflict somehow with Python testing. If `skipTests={anyvalue}` is set, then exec plugin is not executed ...
}
util.runWithPythonVirtualEnv(mvnCmd.getFullRunCommand('clean install'), 'swf')
mvnCmd.run('clean install')
}
}
}
Expand Down Expand Up @@ -259,7 +248,7 @@ void commitAndCreatePR() {
prBody += '\nPlease review and merge.'
}
// Not using githubscm.commitChanges() because globbing won't work.
// See: https://github.com/kiegroup/kogito-runtimes/pull/570#discussion_r449268738
// See: https://github.com/apache/incubator-kie-kogito-runtimes/pull/570#discussion_r449268738
addNotIgnoredPoms()
sh "git commit -m '${commitMsg}'"
githubscm.pushObject('origin', getPRBranch(), getGitAuthorCredsID())
Expand All @@ -275,7 +264,7 @@ boolean shouldStageArtifacts() {
}

boolean shouldDeployToRepository() {
return env.MAVEN_DEPLOY_REPOSITORY && env.MAVEN_REPO_CREDS_ID && getGitAuthor() == 'kiegroup'
return env.MAVEN_DEPLOY_REPOSITORY && env.MAVEN_REPO_CREDS_ID && getGitAuthor() == 'apache'
}

boolean isRelease() {
Expand Down Expand Up @@ -347,7 +336,7 @@ void runMavenDeploy(boolean localDeployment = false) {

mvnCmd.skipTests(true).run('clean deploy')

util.runWithPythonVirtualEnv(mvnCmd.skipTests(true).getFullRunCommand('clean deploy'), 'swf')
mvnCmd.skipTests(true).run('clean deploy')
}

void runMavenStage() {
Expand Down
23 changes: 4 additions & 19 deletions .ci/jenkins/Jenkinsfile.post-release
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import org.jenkinsci.plugins.workflow.libs.Library

pipeline {
agent {
label 'kie-rhel8 && !built-in'
}

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 {
Expand All @@ -19,7 +17,6 @@ pipeline {

environment {
CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
GITHUB_CLI_VERSION = '0.11.1'
}

stages {
Expand All @@ -34,10 +31,7 @@ pipeline {

// Verify version is set and if on right release branch
assert getProjectVersion()

assert getBuildBranch() == util.getReleaseBranchFromVersion(getProjectVersion())

installGithubCLI()
}
}
}
Expand Down Expand Up @@ -112,15 +106,6 @@ void checkoutTag(String repo, String tagName, String localBranchName = tagName)
sh "git checkout tags/${tagName} -b ${localBranchName}"
}

void installGithubCLI() {
sh """
wget https://github.com/cli/cli/releases/download/v${env.GITHUB_CLI_VERSION}/gh_${env.GITHUB_CLI_VERSION}_linux_amd64.tar.gz
tar xzf gh_${env.GITHUB_CLI_VERSION}_linux_amd64.tar.gz
mv gh_${env.GITHUB_CLI_VERSION}_linux_amd64/bin/gh .
rm -r gh_${env.GITHUB_CLI_VERSION}_linux_amd64*
"""
}

void setDefaultBranch(String defaultBranch) {
withCredentials([string(credentialsId: env.GITHUB_TOKEN_CREDS_ID, variable: 'GITHUB_TOKEN')]) {
// gh command from https://github.com/cli/cli/issues/929#issuecomment-629253585
Expand Down
5 changes: 4 additions & 1 deletion .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ examplesHelper = null

pipeline {
agent {
label 'rhel8 && !built-in'
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}

options {
Expand Down
15 changes: 7 additions & 8 deletions .ci/jenkins/Jenkinsfile.quarkus-3.rewrite.pr
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ changeTarget = env.ghprbTargetBranch ?: CHANGE_TARGET

pipeline {
agent {
label 'kie-rhel8 && docker && kie-mem16g && !built-in'
}
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()
Expand All @@ -38,9 +37,9 @@ pipeline {
stage('Build upstream projects') {
steps {
script {
[ 'drools', 'kogito-runtimes', 'kogito-apps' ].each { project ->
[ 'incubator-kie-drools', 'incubator-kie-kogito-runtimes', 'incubator-kie-kogito-apps' ].each { project ->
dir(project) {
githubscm.checkoutIfExists(project, changeAuthor, changeBranch, 'kiegroup', changeTarget, true)
githubscm.checkoutIfExists(project, changeAuthor, changeBranch, 'apache', changeTarget, true)
sh '.ci/environments/update.sh quarkus-3'
getMavenCommand().withProperty('quickly').run('clean install')
}
Expand All @@ -56,7 +55,7 @@ pipeline {
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}"

util.runWithPythonVirtualEnv('.ci/environments/quarkus-3/before.sh rewrite', 'swf')
sh '.ci/environments/quarkus-3/before.sh rewrite'
}
}
}
Expand Down
14 changes: 6 additions & 8 deletions .ci/jenkins/Jenkinsfile.quarkus-3.rewrite.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ previousHash = ''

pipeline {
agent {
label 'kie-rhel8 && docker && kie-mem16g && !built-in'
}

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 {
Expand Down Expand Up @@ -57,7 +55,7 @@ pipeline {
stage('Build upstream projects') {
steps {
script {
[ 'drools', 'kogito-runtimes', 'kogito-apps' ].each { project ->
[ 'incubator-kie-drools', 'incubator-kie-kogito-runtimes', 'incubator-kie-kogito-apps' ].each { project ->
dir(project) {
githubscm.checkoutIfExists(project, getGitAuthor(), getBuildBranch(), getBaseAuthor(), getBaseBranch(), true)
sh '.ci/environments/update.sh quarkus-3'
Expand All @@ -75,7 +73,7 @@ pipeline {
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}"

util.runWithPythonVirtualEnv('.ci/environments/quarkus-3/before.sh rewrite', 'swf')
sh '.ci/environments/quarkus-3/before.sh rewrite'
}
}
}
Expand Down
25 changes: 7 additions & 18 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,25 @@ import org.kie.jenkins.MavenCommand

examplesHelper = null

droolsRepo = 'drools'
kogitoRuntimesRepo = 'kogito-runtimes'
kogitoAppsRepo = 'kogito-apps'
droolsRepo = 'incubator-kie-drools'
kogitoRuntimesRepo = 'incubator-kie-kogito-runtimes'
kogitoAppsRepo = 'incubator-kie-kogito-apps'

pipeline {
agent {
label 'kie-rhel8 && !built-in'
}

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

KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

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

stages {
Expand Down
22 changes: 12 additions & 10 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.JenkinsFolder
Expand Down Expand Up @@ -67,7 +67,7 @@ List getExamplesBuildMvnOptions(JenkinsFolder jobFolder) {
}

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

// Init branch
createSetupBranchJob()
Expand Down Expand Up @@ -98,7 +98,9 @@ if (isMainStream()) {

// Quarkus 3
if (EnvUtils.isEnvironmentEnabled(this, 'quarkus-3')) {
setupPrQuarkus3RewriteJob()
// Deactivated due to ghprb not available on Apache Jenkins
// TODO create PR job with branch source plugin
// setupPrQuarkus3RewriteJob()
setupStandaloneQuarkus3RewriteJob()
}
}
Expand All @@ -117,7 +119,7 @@ void setupSpecificBuildChainNightlyJob(String envName, Closure defaultJobParamsG

void createSetupBranchJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples', JobType.SETUP_BRANCH, "${jenkins_path}/Jenkinsfile.setup-branch", 'Kogito Examples Init branch')
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",

Expand All @@ -144,7 +146,7 @@ void createSetupBranchJob() {

void setupReleaseDeployJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples-deploy', JobType.RELEASE, "${jenkins_path}/Jenkinsfile.deploy", 'Kogito Examples Deploy')
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
PROPERTIES_FILE_NAME: 'deployment.properties',

Expand Down Expand Up @@ -186,7 +188,7 @@ void setupReleaseDeployJob() {

void setupReleasePromoteJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples-promote', JobType.RELEASE, "${jenkins_path}/Jenkinsfile.promote", 'Kogito Examples Promote')
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
PROPERTIES_FILE_NAME: 'deployment.properties',

Expand Down Expand Up @@ -222,7 +224,7 @@ void setupReleasePromoteJob() {

void setupPostReleaseJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples-post-release', JobType.RELEASE, "${jenkins_path}/Jenkinsfile.post-release", 'Kogito Examples Post Release')
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",

Expand All @@ -246,7 +248,7 @@ void setupPostReleaseJob() {

void setupPrQuarkus3RewriteJob() {
def jobParams = JobParamsUtils.getBasicJobParamsWithEnv(this, 'kogito-examples.rewrite', JobType.PULL_REQUEST, 'quarkus-3', "${jenkins_path}/Jenkinsfile.quarkus-3.rewrite.pr", 'Kogito Examples Quarkus 3 rewrite patch regeneration')
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.jenkinsfile = "${jenkins_path}/Jenkinsfile.quarkus-3.rewrite.pr"
jobParams.pr.putAll([
run_only_for_branches: [ "${GIT_BRANCH}" ],
Expand All @@ -266,7 +268,7 @@ void setupPrQuarkus3RewriteJob() {
void setupStandaloneQuarkus3RewriteJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-examples.quarkus-3.rewrite', JobType.TOOLS, "${jenkins_path}/Jenkinsfile.quarkus-3.rewrite.standalone", 'Kogito Examples Quarkus 3 rewrite patch regeneration')
jobParams.env.putAll(EnvUtils.getEnvironmentEnvVars(this, 'quarkus-3'))
JobParamsUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
Expand Down
Loading

0 comments on commit a3b3764

Please sign in to comment.