Skip to content

Commit

Permalink
Revert "kie-issues#574 Initial ASF Jenkins CI Setup (apache#1703)"
Browse files Browse the repository at this point in the history
This reverts commit 9ad98ac.
  • Loading branch information
rgdoliveira committed Oct 10, 2023
1 parent 5fac5e9 commit 2e22ecb
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 49 deletions.
22 changes: 17 additions & 5 deletions .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

pipeline {
agent {
label 'ubuntu'
label 'rhel8 && !built-in'
}
tools {
maven env.BUILD_MAVEN_TOOL
jdk env.BUILD_JDK_TOOL
}
options {
timeout(time: 120, unit: 'MINUTES')
Expand All @@ -15,7 +19,7 @@ pipeline {

sh 'printenv'

githubscm.checkoutIfExists(getRepoName(), getChangeAuthor(), getChangeBranch(), 'apache', getChangeTarget(), true)
githubscm.checkoutIfExists(getRepoName(), getChangeAuthor(), getChangeBranch(), 'kiegroup', getChangeTarget(), true)
}
}
}
Expand Down Expand Up @@ -52,7 +56,7 @@ pipeline {
}
unsuccessful {
script {
pullrequest.postComment(util.getMarkdownTestSummary('PR', "${BUILD_URL}", 'GITHUB'))
pullrequest.postComment(util.getMarkdownTestSummary(isProdCI() ? 'Prod' : 'PR', '', "${BUILD_URL}", 'GITHUB'))
}
}
}
Expand All @@ -73,7 +77,7 @@ Closure createBuildAndTestStageClosure(String image) {
buildParams.add(string(name: 'TARGET_BRANCH', value: getChangeTarget()))
buildParams.add(string(name: 'BUILD_KOGITO_APPS_REF', value: getChangeTarget()))

githubscm.prepareCommitStatusInformationForPullRequest(getRepoName(), getChangeAuthor(), getChangeBranch(), 'apache', getGitAuthorCredentialsId())
githubscm.prepareCommitStatusInformationForPullRequest(getRepoName(), getChangeAuthor(), getChangeBranch(), 'kiegroup', getGitAuthorCredentialsId())
githubscm.updateGithubCommitStatus(image, 'PENDING', 'Queued', getRepoName())

// Keep executing so we can cancel all if needed
Expand All @@ -93,7 +97,15 @@ String[] getImages() {
if (env.IMAGES_LIST) {
return env.IMAGES_LIST.split(',')
}
return sh(returnStdout: true, script: "make list | tr '\\n' ','").trim().split(',')
String listCmd = 'make list'
if (isProdCI()) {
listCmd += ' arg=--prod'
}
return util.runWithPythonVirtualEnv("${listCmd} | tr '\\n' ','", 'cekit', true).trim().split(',')
}

boolean isProdCI() {
return env.PROD_CI ? env.PROD_CI.toBoolean() : false
}

String getChangeAuthor() {
Expand Down
22 changes: 17 additions & 5 deletions .ci/jenkins/Jenkinsfile.build-image
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ QUAY_REGISTRY = 'quay.io'

pipeline {
agent {
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
label 'kie-rhel8 && docker && !built-in'
}
tools {
maven env.BUILD_MAVEN_TOOL
jdk env.BUILD_JDK_TOOL
}
options {
timeout(time: 120, unit: 'MINUTES')
}
environment {
CI = true

// Linked to node label
// Use docker due to multiplatform build
CONTAINER_ENGINE = 'docker'
Expand Down Expand Up @@ -46,6 +49,11 @@ pipeline {
}
updateGithubCommitStatus('PENDING', 'Started')

if (isProdCI()) {
// Prod fix to be able to build the image as a community one
sh "echo '' > content_sets.yaml"
}

// Login to final registry if deploy is needed
if (shouldDeployImage()) {
if (isDeployImageInOpenshiftRegistry()) {
Expand Down Expand Up @@ -245,7 +253,7 @@ String getBuiltImageTag(String imageTag = '') {
}

void runPythonCommand(String cmd, boolean stdout = false) {
return sh(returnStdout: stdout, script: cmd)
return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout)
}

////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -356,6 +364,10 @@ String getMavenArtifactRepository() {
return params.MAVEN_ARTIFACTS_REPOSITORY
}

boolean isProdCI() {
return env.PROD_CI ? Boolean.parseBoolean(env.PROD_CI) : false
}

String getQuarkusPlatformURL() {
return params.QUARKUS_PLATFORM_URL
}
Expand Down
13 changes: 8 additions & 5 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ TEST_FAILED_IMAGES = []

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

// Needed for local build
tools {
maven env.BUILD_MAVEN_TOOL
jdk env.BUILD_JDK_TOOL
}

options {
Expand Down Expand Up @@ -418,7 +421,7 @@ String[] getImages() {
}

void runPythonCommand(String cmd, boolean stdout = false) {
return sh(returnStdout: stdout, script: cmd)
return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout)
}

String getQuarkusPlatformVersion() {
Expand Down
17 changes: 10 additions & 7 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ deployProperties = [:]

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

options {
timeout(time: 120, 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}")

CONTAINER_ENGINE = 'docker'
CONTAINER_ENGINE_TLS_OPTIONS = ''
// Linked to node label
CONTAINER_ENGINE = 'podman'
CONTAINER_ENGINE_TLS_OPTIONS = '--tls-verify=false'

OPENSHIFT_API = credentials('OPENSHIFT_API')
OPENSHIFT_REGISTRY = credentials('OPENSHIFT_REGISTRY')
Expand Down Expand Up @@ -356,5 +359,5 @@ String[] getImages() {
}

void runPythonCommand(String cmd, boolean stdout = false) {
return sh(returnStdout: stdout, script: cmd)
return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout)
}
21 changes: 16 additions & 5 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@ import org.jenkinsci.plugins.workflow.libs.Library

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

// Needed for local build
tools {
maven env.BUILD_MAVEN_TOOL
jdk env.BUILD_JDK_TOOL
}

options {
timeout(time: 120, 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}")

JAVA_HOME = "${GRAALVM_HOME}"
}

stages {
Expand Down Expand Up @@ -171,5 +182,5 @@ String getCleanedReleaseNotes() {
}

void runPythonCommand(String cmd, boolean stdout = false) {
return sh(returnStdout: stdout, script: cmd)
return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout)
}
103 changes: 103 additions & 0 deletions .ci/jenkins/Jenkinsfile.update-prod-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
@Library('jenkins-pipeline-shared-libraries')_

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

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

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

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

PR_BRANCH_HASH = "${util.generateHash(10)}"
}

stages {
stage('Initialization') {
steps {
script {
assert getProdProjectVersion()
assert getJiraNumber()

currentBuild.displayName = getProdProjectVersion()

deleteDir()
checkout(githubscm.resolveRepository(getRepoName(), getGitAuthor(), getBuildBranch(), false))
}
}
}
stage('Prepare for PR') {
steps {
script {
githubscm.createBranch(getPRBranch())
}
}
}
stage('Update prod version') {
when {
expression { return getProdProjectVersion() != '' }
}
steps {
script {
sh "python3 scripts/manage-kogito-version.py --bump-to ${getProdProjectVersion()} --confirm --prod"
}
}
}
stage('Create PR') {
steps {
script {
String commitMsg = "[${getJiraNumber()}] Update product version to ${getProdProjectVersion()}"
if (githubscm.isThereAnyChanges()) {
githubscm.commitChanges(commitMsg)
} else {
error 'No update version can be done'
}
githubscm.pushObject('origin', getPRBranch(), getGitAuthorCredsID())
String prLink = githubscm.createPR(commitMsg, 'Please review and merge', getBuildBranch(), getGitAuthorCredsID())

echo "Created PR ${prLink}"
}
}
}
}
post {
cleanup {
cleanWs()
}
}
}

String getRepoName() {
return "${REPO_NAME}"
}

String getBuildBranch() {
return "${BUILD_BRANCH_NAME}"
}

String getGitAuthor() {
return "${GIT_AUTHOR}"
}

String getGitAuthorCredsID() {
return env.AUTHOR_CREDS_ID
}

String getPRBranch() {
return "${getProdProjectVersion() ?: getBuildBranch()}-${env.PR_BRANCH_HASH}"
}

String getProdProjectVersion() {
return "${PROD_PROJECT_VERSION}"
}

String getJiraNumber() {
return "${JIRA_NUMBER}"
}
Loading

0 comments on commit 2e22ecb

Please sign in to comment.