This is an automated email from the ASF dual-hosted git repository.
jstastnycz pushed a commit to branch radtriste-fix-pipelines
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-images.git
The following commit(s) were added to refs/heads/radtriste-fix-pipelines by
this push:
new c912b283 pass PR source repository name
c912b283 is described below
commit c912b283e83e8b4502da6f682e5181959f30fdc9
Author: jstastny-cz <[email protected]>
AuthorDate: Wed Nov 8 17:39:16 2023 +0100
pass PR source repository name
---
.ci/jenkins/Jenkinsfile | 19 ++++++++++---------
.ci/jenkins/Jenkinsfile.build-and-test | 4 ++--
.ci/jenkins/dsl/jobs.groovy | 2 ++
3 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/.ci/jenkins/Jenkinsfile b/.ci/jenkins/Jenkinsfile
index 16174a51..6a27f963 100644
--- a/.ci/jenkins/Jenkinsfile
+++ b/.ci/jenkins/Jenkinsfile
@@ -13,11 +13,12 @@ pipeline {
stage("Build&Test") {
steps {
script {
- sh 'env'
+ sh 'printenv'
List buildParams = []
- buildParams.add(string(name: "DISPLAY_NAME", value: "PR
#${CHANGE_ID}: ${CHANGE_URL}"))
- buildParams.add(string(name: "CHANGE_ID", value:
CHANGE_ID))
- buildParams.add(string(name: "CHANGE_URL", value:
CHANGE_URL))
+ buildParams.add(string(name: 'DISPLAY_NAME', value: "PR
#${CHANGE_ID}: ${CHANGE_URL}"))
+ buildParams.add(string(name: 'CHANGE_ID', value:
CHANGE_ID))
+ buildParams.add(string(name: 'CHANGE_URL', value:
CHANGE_URL))
+ buildParams.add(string(name: 'SOURCE_REPOSITORY', value:
getChangeRepository()))
buildParams.add(string(name: 'SOURCE_AUTHOR', value:
getChangeAuthor()))
buildParams.add(string(name: 'SOURCE_BRANCH', value:
getChangeBranch()))
buildParams.add(string(name: 'TARGET_BRANCH', value:
getChangeTarget()))
@@ -38,7 +39,11 @@ pipeline {
}
String getChangeAuthor() {
- return CHANGE_AUTHOR
+ return pullrequest.getAuthorAndRepoForPr().split('/')[0]
+}
+
+String getChangeRepository() {
+ return pullrequest.getAuthorAndRepoForPr().split('/')[1]
}
String getChangeBranch() {
@@ -49,10 +54,6 @@ String getChangeTarget() {
return CHANGE_TARGET
}
-String getRepoName() {
- return env.REPO_NAME
-}
-
String getGitAuthorCredentialsId() {
return env.AUTHOR_CREDS_ID
}
diff --git a/.ci/jenkins/Jenkinsfile.build-and-test
b/.ci/jenkins/Jenkinsfile.build-and-test
index 12eb8a76..a6c91e4b 100644
--- a/.ci/jenkins/Jenkinsfile.build-and-test
+++ b/.ci/jenkins/Jenkinsfile.build-and-test
@@ -9,6 +9,7 @@ pipeline {
}
options {
timeout(time: 120, unit: 'MINUTES')
+ skipDefaultCheckout()
}
stages {
stage('Initialization') {
@@ -17,10 +18,9 @@ pipeline {
sh 'printenv'
dir(getRepoName()) {
- // githubscm.checkoutIfExists(getRepoName(),
getChangeAuthor(), getChangeBranch(), 'apache', getChangeTarget(), true,
credentials = [token: getGitAuthorCredentialsId(), usernamePassword: 'kie-ci'])
// TODO Test pupose
deleteDir()
-
checkout(githubscm.resolveRepository('incubator-kie-kogito-images', 'apache',
'radtriste-fix-pipelines', false))
+ githubscm.checkoutIfExists(getRepoName(),
getChangeAuthor(), getChangeBranch(), 'apache', getChangeTarget(), true,
credentials = [token: getGitAuthorCredentialsId(), usernamePassword: 'kie-ci'])
}
}
}
diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy
index cf649084..2d850867 100644
--- a/.ci/jenkins/dsl/jobs.groovy
+++ b/.ci/jenkins/dsl/jobs.groovy
@@ -186,6 +186,7 @@ void setupBuildAndTestJob(JobType jobType) {
def jobParams = JobParamsUtils.getBasicJobParams(this,
'kogito-images.build-and-test', jobType,
"${jenkins_path}/Jenkinsfile.build-and-test", 'Kogito Images Build And test
images')
// Use jenkinsfile from the build branch
jobParams.git.author = '${SOURCE_AUTHOR}'
+ jobParams.git.repository = '${SOURCE_REPOSITORY}'
jobParams.git.branch = '${SOURCE_BRANCH}'
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this,
jobParams)
jobParams.env.putAll([
@@ -206,6 +207,7 @@ void setupBuildAndTestJob(JobType jobType) {
stringParam('DISPLAY_NAME', '', 'Setup a specific build display
name')
stringParam('SOURCE_AUTHOR', Utils.getGitAuthor(this), 'Build
author')
+ stringParam('SOURCE_REPOSITORY', Utils.getRepoName(this), 'Build
repository name')
stringParam('SOURCE_BRANCH', Utils.getGitBranch(this), 'Build
branch name')
stringParam('TARGET_BRANCH', '', '(Optional) In case of a PR to
merge with target branch, please provide the target branch')
stringParam('CHANGE_ID', '', 'CHANGE_ID coming from Branch Source
Plugin')
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]