Skip to content

Commit

Permalink
kie-issues#600: set credentials for buildchain (#1103)
Browse files Browse the repository at this point in the history
Co-authored-by: jstastny-cz <[email protected]>
  • Loading branch information
jstastny-cz and jstastny-cz authored Oct 4, 2023
1 parent e5d0c77 commit da32d41
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .ci/jenkins/config/branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ buildchain_config:
git:
repository: incubator-kie-kogito-pipelines
file_path: .ci/pull-request-config.yaml
token_credentials_id: kie-ci3-token
maven:
settings_file_id: kie-release-settings
nexus:
Expand Down
7 changes: 5 additions & 2 deletions dsl/seed/jenkinsfiles/Jenkinsfile.buildchain
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pipeline {
}

configFileProvider([configFile(fileId: settingsXmlId, variable: 'MAVEN_SETTINGS_FILE')]) {
withCredentials([string(credentialsId: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}", variable: 'GITHUB_TOKEN')]) {
withCredentials([string(credentialsId: "${BUILDCHAIN_CONFIG_GIT_TOKEN_CREDENTIALS_ID}", variable: 'GITHUB_TOKEN')]) {
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}"

Expand Down Expand Up @@ -176,14 +176,17 @@ pipeline {
unsuccessful {
script {
if (isPRBuildChainType()) {
pullrequest.postComment(util.getMarkdownTestSummary(notificationJobName, getReproducer(true), "${BUILD_URL}", 'GITHUB'), "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}")
pullrequest.postComment(util.getMarkdownTestSummary(notificationJobName, getReproducer(true), "${BUILD_URL}", 'GITHUB'), "${BUILDCHAIN_CONFIG_GIT_TOKEN_CREDENTIALS_ID}")
} else if (shouldNotify()) {
withCredentials([string(credentialsId: "${JENKINS_EMAIL_CREDS_ID}", variable: 'KOGITO_CI_EMAIL_TO')]) {
mailer.sendMarkdownTestSummaryNotification(env.NOTIFICATION_JOB_NAME ?: '', "[${env.GIT_BRANCH_NAME}] ${getRepoNameCamelCase(env.REPO_NAME)}", [env.KOGITO_CI_EMAIL_TO], getReproducer())
}
}
}
}
cleanup {
cleanWs()
}
// cleanup {
// script {
// // Clean also docker in case of usage of testcontainers lib
Expand Down
4 changes: 4 additions & 0 deletions dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ class Utils {
return getBindingValue(script, 'BUILDCHAIN_CONFIG_GIT_FILE_PATH')
}

static String getBuildChainConfigTokenCredentialsId(def script) {
return getBindingValue(script, 'BUILDCHAIN_CONFIG_GIT_TOKEN_CREDENTIALS_ID')
}

static String getMavenArtifactsUploadRepositoryUrl(def script) {
return getBindingValue(script, 'MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_URL')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class JobParamsUtils {
BUILDCHAIN_CONFIG_AUTHOR: Utils.getBuildChainConfigAuthor(script) ?: Utils.getSeedAuthor(script),
BUILDCHAIN_CONFIG_BRANCH: Utils.getBuildChainConfigBranch(script) ?: Utils.getSeedBranch(script),
BUILDCHAIN_CONFIG_FILE_PATH: Utils.getBuildChainConfigFilePath(script),
BUILDCHAIN_CONFIG_GIT_TOKEN_CREDENTIALS_ID: Utils.getBuildChainConfigTokenCredentialsId(script) ?: Utils.getGitAuthorTokenCredsId(script),
NOTIFICATION_JOB_NAME: notificationJobName,
GIT_AUTHOR_TOKEN_CREDENTIALS_ID: Utils.getGitAuthorTokenCredsId(script),
])
addJobParamsEnvIfNotExisting(script, jobParams, 'BUILD_ENVIRONMENT', jobParams.job.folder.getEnvironmentName())
}
Expand Down

0 comments on commit da32d41

Please sign in to comment.