Skip to content

Commit

Permalink
[10.0.x] CI duplicate maven configuration entries (apache#1254)
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 committed Oct 18, 2024
1 parent 07c43fc commit 830610a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
14 changes: 11 additions & 3 deletions .ci/jenkins/config/branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ buildchain_config:
file_path: .ci/pull-request-config.yaml
token_credentials_id: kie-ci3-token
maven:
settings_file_id: kie-release-settings
settings:
nightly:
config_file_id: kie-nightly-settings
release:
config_file_id: kie-release-settings
nexus:
release_url: TO_DEFINE
release_repository: TO_DEFINE
Expand All @@ -73,8 +77,12 @@ maven:
build_promotion_profile_id: TO_DEFINE
artifacts_repository: ''
artifacts_upload_repository:
url: https://repository.apache.org/content/repositories/snapshots
creds_id: apache-nexus-kie-deploy-credentials
nightly:
url: https://repository.apache.org/content/repositories/snapshots
creds_id: apache-nexus-kie-deploy-credentials
release:
url: https://repository.apache.org/service/local/staging/deploy/maven2
creds_id: jenkins-deploy-to-nexus-staging
quarkus_platform_repository:
url: TO_DEFINE
creds_id: TO_DEFINE
Expand Down
4 changes: 2 additions & 2 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void setupWeeklyCloudJob() {
IMAGE_NAMESPACE: "${CLOUD_IMAGE_NAMESPACE}",
BRANCH_FOR_LATEST: "${CLOUD_IMAGE_LATEST_GIT_BRANCH}",

MAVEN_SETTINGS_CONFIG_FILE_ID: "${MAVEN_SETTINGS_FILE_ID}",
MAVEN_SETTINGS_CONFIG_FILE_ID: Utils.getMavenSettingsConfigFileId(this, JobType.NIGHTLY.name),
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
Expand Down Expand Up @@ -238,7 +238,7 @@ void setupNightlyCloudJob() {
IMAGE_NAMESPACE: "${CLOUD_IMAGE_NAMESPACE}",
BRANCH_FOR_LATEST: "${CLOUD_IMAGE_LATEST_GIT_BRANCH}",

MAVEN_SETTINGS_CONFIG_FILE_ID: "${MAVEN_SETTINGS_FILE_ID}",
MAVEN_SETTINGS_CONFIG_FILE_ID: Utils.getMavenSettingsConfigFileId(this, JobType.NIGHTLY.name),
ARTIFACTS_REPOSITORY: "${MAVEN_ARTIFACTS_REPOSITORY}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class KogitoJobUtils {
def jobParams = JobParamsUtils.getSeedJobParamsWithEnv(script, "${Utils.getRepositoryJobDisplayName(script, repository)}.build-and-test", JobType.NIGHTLY, envName, KogitoConstants.BUILD_CHAIN_JENKINSFILE, "Build & Test for ${repository} using the build-chain", defaultJobParamsGetter)
jobParams.env.putAll(extraEnv)
jobParams.triggers = jobParams.triggers ?: [ cron : '@midnight' ] // To remove once environment nightlies are managed by main nightly pipeline
return createBranchBuildChainJob(script, jobParams, repository, enableNotification, envName)
return createBranchBuildChainJob(script, JobType.NIGHTLY, jobParams, repository, enableNotification, envName)
}

/**
Expand All @@ -280,9 +280,9 @@ class KogitoJobUtils {
*/
static def createNightlyBuildChainBuildAndDeployJob(def script, String envName = '', String repository, Map extraEnv = [:], boolean enableNotification = false, Closure defaultJobParamsGetter = JobParamsUtils.DEFAULT_PARAMS_GETTER) {
def jobParams = JobParamsUtils.getSeedJobParamsWithEnv(script, "${Utils.getRepositoryJobDisplayName(script, repository)}.build-and-deploy", JobType.NIGHTLY, envName, KogitoConstants.BUILD_CHAIN_JENKINSFILE, "Build & Deploy for ${repository} using the build-chain", defaultJobParamsGetter)
JobParamsUtils.setupJobParamsDeployConfiguration(script, jobParams)
JobParamsUtils.setupJobParamsDeployConfiguration(script, JobType.NIGHTLY, jobParams)
jobParams.env.putAll(extraEnv)
return createBranchBuildChainJob(script, jobParams, repository, enableNotification, envName)
return createBranchBuildChainJob(script, JobType.NIGHTLY, jobParams, repository, enableNotification, envName)
}

/**
Expand All @@ -292,7 +292,7 @@ class KogitoJobUtils {
*
*/
static def createNightlyBuildChainIntegrationJob(def script, String envName, String repository, boolean enableNotification = false, Closure defaultJobParamsGetter = JobParamsUtils.DEFAULT_PARAMS_GETTER) {
return createBuildChainIntegrationJob(script, envName, repository, enableNotification) { jenkinsScript ->
return createBuildChainIntegrationJob(script, JobType.NIGHTLY, envName, repository, enableNotification) { jenkinsScript ->
def jobParams = defaultJobParamsGetter(jenkinsScript)
jobParams.triggers = jobParams.triggers ?: [ cron : '@midnight' ] // To remove once environment nightlies are managed by main nightly pipeline
return jobParams
Expand All @@ -305,13 +305,13 @@ class KogitoJobUtils {
* This job will call the build-chain with extra environment variables to allow for the creation of an integration branch
*
*/
static def createBuildChainIntegrationJob(def script, String envName, String repository, boolean enableNotification = false, Closure defaultJobParamsGetter = JobParamsUtils.DEFAULT_PARAMS_GETTER) {
static def createBuildChainIntegrationJob(def script, JobType jobType, String envName, String repository, boolean enableNotification = false, Closure defaultJobParamsGetter = JobParamsUtils.DEFAULT_PARAMS_GETTER) {
def jobParams = JobParamsUtils.getSeedJobParamsWithEnv(script, "${Utils.getRepositoryJobDisplayName(script, repository)}.integration", JobType.NIGHTLY, envName, KogitoConstants.BUILD_CHAIN_JENKINSFILE, "Integration with Quarkus for ${repository} using the build-chain", defaultJobParamsGetter)
if (!envName) {
throw new RuntimeException('Please provide a non-empty environment to generate an integration branch job...')
}
JobParamsUtils.setupJobParamsIntegrationBranchConfiguration(script, jobParams, envName)
return createBranchBuildChainJob(script, jobParams, repository, enableNotification, envName)
return createBranchBuildChainJob(script, jobType, jobParams, repository, enableNotification, envName)
}

/**
Expand All @@ -323,7 +323,7 @@ class KogitoJobUtils {
* - enableNotification: Whether notification should be sent in case of unsuccessful pipeline
* - notificationJobName: Identifier for the notification stream
*/
static def createBranchBuildChainJob(def script, def jobParams, String repository, boolean enableNotification = false, String notificationJobName = '') {
static def createBranchBuildChainJob(def script, JobType jobType, def jobParams, String repository, boolean enableNotification = false, String notificationJobName = '') {
JobParamsUtils.setupJobParamsBuildChainConfiguration(script, jobParams, repository, 'branch', notificationJobName)

jobParams.parametersClosures.add({
Expand All @@ -340,7 +340,7 @@ class KogitoJobUtils {

GIT_AUTHOR: Utils.getGitAuthor(script),

MAVEN_SETTINGS_CONFIG_FILE_ID: Utils.getBindingValue(script, 'MAVEN_SETTINGS_FILE_ID'),
MAVEN_SETTINGS_CONFIG_FILE_ID: Utils.getMavenSettingsConfigFileId(script, jobType.name),
])

return KogitoJobTemplate.createPipelineJob(script, jobParams)
Expand Down
12 changes: 8 additions & 4 deletions dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ class Utils {
return getBindingValue(script, 'BUILDCHAIN_CONFIG_GIT_TOKEN_CREDENTIALS_ID')
}

static String getMavenArtifactsUploadRepositoryUrl(def script) {
return getBindingValue(script, 'MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_URL')
static String getMavenArtifactsUploadRepositoryUrl(def script, String jobType = "nightly") {
return getBindingValue(script, "MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_${jobType.toUpperCase()}_URL")
}

static String getMavenArtifactsUploadRepositoryCredentialsId(def script) {
return getBindingValue(script, 'MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_CREDS_ID')
static String getMavenArtifactsUploadRepositoryCredentialsId(def script, String jobType = "nightly") {
return getBindingValue(script, "MAVEN_ARTIFACTS_UPLOAD_REPOSITORY_${jobType.toUpperCase()}_CREDS_ID")
}

static String getMavenQuarkusPlatformRepositoryUrl(def script) {
Expand All @@ -274,6 +274,10 @@ class Utils {
return getBindingValue(script, 'MAVEN_QUARKUS_PLATFORM_REPOSITORY_CREDS_ID')
}

static String getMavenSettingsConfigFileId(def script, String jobType = 'nightly') {
return getBindingValue(script, "MAVEN_SETTINGS_${jobType.toUpperCase()}_CONFIG_FILE_ID")
}

static String getJenkinsAgentDockerImage(def script, String imageId) {
return getBindingValue(script, "JENKINS_AGENT_DOCKER_${imageId.toUpperCase()}_IMAGE")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ class JobParamsUtils {
addJobParamsEnvIfNotExisting(script, jobParams, 'INTEGRATION_BRANCH_CURRENT', "${Utils.getGenerationBranch(script)}-integration-${envName}")
}

static def setupJobParamsDeployConfiguration(def script, def jobParams) {
static def setupJobParamsDeployConfiguration(def script, JobType jobType, def jobParams) {
jobParams.env = jobParams.env ?: [:]
jobParams.env.put('ENABLE_DEPLOY', String.valueOf(!Utils.isDeployDisabled(script)))
addJobParamsEnvIfNotExisting(script, jobParams, 'MAVEN_DEPLOY_REPOSITORY', Utils.getMavenArtifactsUploadRepositoryUrl(script))
addJobParamsEnvIfNotExisting(script, jobParams, 'MAVEN_DEPLOY_REPOSITORY_CREDS_ID', Utils.getMavenArtifactsUploadRepositoryCredentialsId(script))
addJobParamsEnvIfNotExisting(script, jobParams, 'MAVEN_DEPLOY_REPOSITORY_CREDS_ID', Utils.getMavenArtifactsUploadRepositoryCredentialsId(script, jobType.name))
}

static def setupJobParamsAgentDockerBuilderImageConfiguration(def script, def jobParams) {
Expand Down

0 comments on commit 830610a

Please sign in to comment.