Skip to content

Commit

Permalink
[apache_migration] update pipelines (#1790)
Browse files Browse the repository at this point in the history
* Setup jenkinsfile

* update pipelines
  • Loading branch information
radtriste committed Sep 8, 2023
1 parent 9480af7 commit e09a8c4
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 72 deletions.
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 env.ADDITIONAL_LABEL?.trim() ?: 'ubuntu'
}
options {
timestamps()
timeout(time: env.ADDITIONAL_TIMEOUT?.trim() ?: '180', unit: 'MINUTES')
}
environment {
BUILDCHAIN_PROJECT = 'kiegroup/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('kogito-pipelines', 'kiegroup', 'apache_migration', 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()
}
}
}
}
}
}
25 changes: 7 additions & 18 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 '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: 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 @@ -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 '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 {
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 'ubuntu'
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}

options {
Expand Down
11 changes: 5 additions & 6 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 '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()
Expand Down Expand Up @@ -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
12 changes: 5 additions & 7 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 '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 {
Expand Down Expand Up @@ -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
19 changes: 4 additions & 15 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,19 @@ kogitoAppsRepo = 'kogito-apps'

pipeline {
agent {
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

KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

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

stages {
Expand Down
12 changes: 6 additions & 6 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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 @@ -148,7 +148,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 @@ -190,7 +190,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 @@ -226,7 +226,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 @@ -250,7 +250,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 @@ -270,7 +270,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

0 comments on commit e09a8c4

Please sign in to comment.