Skip to content

Commit

Permalink
KOGITO-8144 Add possibility to call script paths (apache#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste authored Oct 20, 2022
1 parent 2f3400b commit 86f90bf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
22 changes: 21 additions & 1 deletion .ci/jenkins/Jenkinsfile.tools.update-dependency-version
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ pipeline {
}
}
}
stage('Call scripts') {
when {
expression { return getScriptCalls() }
}
steps {
script {
dir(getRepoName()) {
getScriptCalls().each { scriptCall ->
sh """
${scriptCall.replaceAll('%new_version%', getNewVersion())}
"""
}
}
}
}
}
stage('Create PRs') {
steps {
script {
Expand Down Expand Up @@ -225,7 +241,11 @@ List getGradleRegex() {
}

List getFilepathReplaceRegex() {
return env.FILEPATH_REPLACE_REGEX ? readJSON(text: env.FILEPATH_REPLACE_REGEX) : []
return env.FILEPATH_REPLACE_REGEX ? readJSON(text: env.FILEPATH_REPLACE_REGEX) : [:]
}

List getScriptCalls() {
return env.SCRIPTS_CALLS ? readJSON(text: env.SCRIPTS_CALLS) : []
}

/**
Expand Down
2 changes: 1 addition & 1 deletion .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ setupCreateIssueToolsJob()
setupCleanOldNamespacesToolsJob()
setupCleanOldNightlyImagesToolsJob()
setupUpdateQuarkusPlatformJob()
KogitoJobUtils.createMainQuarkusUpdateToolsJob(this, 'Kogito Pipelines', [ 'drools', 'kogito-runtimes', 'kogito-examples', 'kogito-docs' ])
KogitoJobUtils.createMainQuarkusUpdateToolsJob(this, 'Kogito Pipelines', [ 'drools', 'kogito-runtimes', 'kogito-examples', 'kogito-images', 'kogito-docs' ])
if (Utils.isMainBranch(this)) {
setupBuildOperatorNode()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,25 @@ class KogitoJobUtils {
return jobParams
}

static def createVersionUpdateToolsJob(def script, String repository, String dependencyName, def mavenUpdate = [:], def gradleUpdate = [:], def filepathReplaceRegex = [:]) {
/**
* Create a version update tools job
*
* @param repository Repository to update
* @param dependencyName Name of the dependency which will be updated
* @param mavenUpdate Maven update configuration
* .modules => Maven bom modules list to update with new version
* .compare_deps_remote_poms => Remote poms to compare dependencies with
* .properties => Properties to update in the given modules
* @param gradleUpdate Gradle update configuration
* .regex => Regex to update the version in build.gradle files
* @param filepathReplaceRegex List of Filepath/Regex sed commands.
* For each element:
* .filepath => Filepath to update
* .regex => Regex to use in sed command
* @param scriptCalls List of script calls string.
*
*/
static def createVersionUpdateToolsJob(def script, String repository, String dependencyName, def mavenUpdate = [:], def gradleUpdate = [:], def filepathReplaceRegex = [], def scriptCalls = []) {
def jobParams = getSeedJobParams(script, "update-${dependencyName.toLowerCase()}-${repository}", Folder.TOOLS, 'Jenkinsfile.tools.update-dependency-version', "Update ${dependencyName} version for ${repository}")
KogitoJobUtils.setupJobParamsDefaultMavenConfiguration(script, jobParams)
// Setup correct checkout branch for pipelines
Expand Down Expand Up @@ -112,6 +130,9 @@ class KogitoJobUtils {
if (filepathReplaceRegex) {
jobParams.env.put('FILEPATH_REPLACE_REGEX', JsonOutput.toJson(filepathReplaceRegex))
}
if (scriptCalls) {
jobParams.env.put('SCRIPTS_CALLS', JsonOutput.toJson(scriptCalls))
}
def job = KogitoJobTemplate.createPipelineJob(script, jobParams)
job?.with {
parameters {
Expand All @@ -125,8 +146,8 @@ class KogitoJobUtils {
/**
* Create a Quarkus update job which allow to update the quarkus version into a repository, via Maven or Gradle
*/
static def createQuarkusUpdateToolsJob(def script, String repository, def mavenUpdate = [:], def gradleUpdate = [:], def filepathReplaceRegex = [:]) {
return createVersionUpdateToolsJob(script, repository, 'Quarkus', mavenUpdate, gradleUpdate, filepathReplaceRegex)
static def createQuarkusUpdateToolsJob(def script, String repository, def mavenUpdate = [:], def gradleUpdate = [:], def filepathReplaceRegex = [], def scriptCalls = []) {
return createVersionUpdateToolsJob(script, repository, 'Quarkus', mavenUpdate, gradleUpdate, filepathReplaceRegex, scriptCalls)
}

/**
Expand Down

0 comments on commit 86f90bf

Please sign in to comment.