This is an automated email from the ASF dual-hosted git repository.
rantunes pushed a commit to branch 10.0.x
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-images.git
The following commit(s) were added to refs/heads/10.0.x by this push:
new 2e4d20eb Kogito Images release deploy job fixes (#1799)
2e4d20eb is described below
commit 2e4d20eb0cd427cc168ffc170631da35d064de6b
Author: Rodrigo Antunes <[email protected]>
AuthorDate: Fri Aug 30 13:17:00 2024 -0300
Kogito Images release deploy job fixes (#1799)
---
.ci/jenkins/Jenkinsfile.build-image | 35 ++++++++++++++++++++++++-----------
.ci/jenkins/Jenkinsfile.deploy | 30 +++++++++++++++++++++++-------
.ci/jenkins/dsl/jobs.groovy | 4 ++--
scripts/common.py | 13 +++++++++++++
scripts/update-repository.py | 4 ++++
5 files changed, 66 insertions(+), 20 deletions(-)
diff --git a/.ci/jenkins/Jenkinsfile.build-image
b/.ci/jenkins/Jenkinsfile.build-image
index 8a89fb28..bd390934 100644
--- a/.ci/jenkins/Jenkinsfile.build-image
+++ b/.ci/jenkins/Jenkinsfile.build-image
@@ -87,19 +87,23 @@ pipeline {
if (getMavenArtifactRepository()) {
echo "Setup Repository url to
'${getMavenArtifactRepository()}'"
- runPythonCommand("python scripts/update-repository.py
--repo-url ${getMavenArtifactRepository()}")
+ runPythonCommand("python scripts/update-repository.py
--repo-urls ${getMavenArtifactRepository()}")
}
}
}
}
- stage('Update kogito version') {
+ stage('Update project version') {
when {
expression { params.UPDATE_KOGITO_VERSION != '' }
}
steps {
script {
- runPythonCommand("python scripts/manage-kogito-version.py
--bump-to ${params.UPDATE_KOGITO_VERSION} --confirm")
+ versionCmd = "python scripts/manage-kogito-version.py
--bump-to ${params.UPDATE_KOGITO_VERSION} --confirm"
+ if (isRelease()) {
+ versionCmd += " --examples-ref ${getSourceBranch()}"
+ }
+ sh versionCmd
}
}
}
@@ -128,7 +132,7 @@ pipeline {
int freePort = cloud.findFreePort()
env.localRegistryUrl = cloud.startLocalRegistry(freePort)
-
cloud.prepareForDockerMultiplatformBuild([env.localRegistryUrl],[cloud.getDockerIOMirrorRegistryConfig()],
false)
+
cloud.prepareForDockerMultiplatformBuild([env.localRegistryUrl],
[cloud.getDockerIOMirrorRegistryConfig()], false)
// Generate the Dockerfile
runPythonCommand("make build-image
${getMakeBuildImageArgs()} image_name=${getBuildImageName()} ignore_test=true
ignore_tag=true build_options='--dry-run'")
@@ -184,7 +188,7 @@ pipeline {
script {
updateGithubCommitStatus('PENDING', 'Tests in progress')
- String testImageTag =
"docker.io/apache/incubator-kie-${getBuildImageName()}:${getImageVersion()}"
+ String testImageTag =
"${getDeployImageRegistry()}/${getDeployImageNamespace()}/incubator-kie-${getBuildImageName()}:${getImageVersion()}"
String builtImageTag = getBuiltImageTag()
// Pull and tag to test image
sh """
@@ -208,11 +212,12 @@ pipeline {
}
steps {
script {
- def resultingFileName =
"incubator-kie-${getImageArtifactReleaseVersion()}-${getBuildImageName()}-image.tar.gz"
- def signatureFileName = "${resultingFileName}.asc"
+ String resultingFileName =
"incubator-kie-${getImageArtifactReleaseVersion()}-${getBuildImageName()}-image.tar.gz"
+ String signatureFileName = "${resultingFileName}.asc"
sh """
docker pull ${getBuiltImageTag()}
- docker save ${getBuiltImageTag()} | gzip >
${resultingFileName}
+ docker tag ${getBuiltImageTag()}
${getBuiltDeployImageTag()}
+ docker save ${getBuiltDeployImageTag()} | gzip >
${resultingFileName}
"""
releaseUtils.gpgImportKeyFromStringWithoutPassword(getReleaseGpgSignKeyCredsId())
releaseUtils.gpgSignFileDetachedSignatureWithoutPassword(resultingFileName,
signatureFileName)
@@ -269,9 +274,13 @@ String getImageVersion() {
return runPythonCommand('make display-image-version', true).trim()
}
+String getBuiltDeployImageTag(String imageTag = '') {
+ return
"${getDeployImageRegistry()}/${getDeployImageNamespace()}/${getFinalImageName()}:${imageTag
?: getDeployImageTag()}"
+}
+
String getBuiltImageTag(String imageTag = '') {
if (shouldDeployImage()) {
- return
"${getDeployImageRegistry()}/${getDeployImageNamespace()}/${getFinalImageName()}:${imageTag
?: getDeployImageTag()}"
+ return getBuiltDeployImageTag(imageTag)
}
return
"${env.localRegistryUrl}/${getBuildImageName()}:${githubscm.getCommitHash()}"
}
@@ -316,7 +325,7 @@ String getDeployImageTag() {
}
String getFinalImageName() {
- return "incubator-kie-" + getBuildImageName() +
(getDeployImageNameSuffix() ? "-${getDeployImageNameSuffix()}" : '')
+ return 'incubator-kie-' + getBuildImageName() +
(getDeployImageNameSuffix() ? "-${getDeployImageNameSuffix()}" : '')
}
boolean isDeployLatestTag() {
@@ -440,7 +449,7 @@ String getTriggeringProjectName() {
if (currentBuild.upstreamBuilds) {
return currentBuild.upstreamBuilds[0].projectName
}
- return ""
+ return ''
}
String getReleaseGpgSignKeyCredsId() {
return env.RELEASE_GPG_SIGN_KEY_CREDS_ID
@@ -461,3 +470,7 @@ String getReleaseSvnCredsId() {
String getImageArtifactReleaseVersion() {
return params.IMAGE_ARTIFACT_RELEASE_VERSION
}
+
+boolean isRelease() {
+ return env.RELEASE ? env.RELEASE.toBoolean() : false
+}
diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy
index c4385436..f62e41b5 100644
--- a/.ci/jenkins/Jenkinsfile.deploy
+++ b/.ci/jenkins/Jenkinsfile.deploy
@@ -24,7 +24,7 @@ TEST_FAILED_IMAGES = Collections.synchronizedList([])
pipeline {
agent {
- docker {
+ docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
label util.avoidFaultyNodes()
@@ -99,14 +99,12 @@ pipeline {
dir(getRepoName()) {
versionCmd = "python scripts/manage-kogito-version.py
--bump-to ${getProjectVersion()} --confirm"
if (getBuildBranch() != 'main') {
- versionCmd += " --examples-ref ${!isRelease() ?
'nightly-' : ''}${getBuildBranch()}"
+ versionCmd += " --examples-ref ${getBuildBranch()}"
}
if (getKogitoArtifactsVersion()) {
versionCmd += " --artifacts-version
${getKogitoArtifactsVersion()}"
}
sh versionCmd
-
- commitAndTagChanges("[${getBuildBranch()}] Update
version to ${getProjectVersion()}")
}
}
}
@@ -154,6 +152,22 @@ pipeline {
}
}
}
+
+ stage('Commit and Tag changes') {
+ when {
+ expression { return isRelease() }
+ }
+ steps {
+ script {
+ if (!getBuildFailedImages()) {
+ dir(getRepoName()) {
+ commitAndTagChanges("[${getBuildBranch()}] Update
version to ${getProjectVersion()}")
+ }
+ }
+ }
+ }
+ }
+
stage('Finalize') {
steps {
script {
@@ -217,16 +231,18 @@ void createBuildAndTestStageClosure(String image) {
List buildParams = []
buildParams.add(string(name: 'DISPLAY_NAME', value:
"${params.DISPLAY_NAME} - ${image}"))
buildParams.add(string(name: 'BUILD_IMAGE_NAME', value: image))
- buildParams.add(string(name: 'SOURCE_AUTHOR', value: isRelease() ?
getGitAuthor() : getGitAuthor()))
- buildParams.add(string(name: 'SOURCE_BRANCH', value: isRelease() ?
getPRBranch() : getBuildBranch()))
+ buildParams.add(string(name: 'SOURCE_AUTHOR', value:
getGitAuthor()))
+ buildParams.add(string(name: 'SOURCE_BRANCH', value:
getBuildBranch()))
- buildParams.add(string(name: 'MAVEN_ARTIFACTS_REPOSITORY', value:
env.MAVEN_ARTIFACT_REPOSITORY ?: (isRelease() ? env.DEFAULT_STAGING_REPOSITORY
: '')))
+ buildParams.add(string(name: 'MAVEN_ARTIFACTS_REPOSITORY', value:
env.MAVEN_ARTIFACT_REPOSITORY))
buildParams.add(string(name: 'BUILD_KOGITO_APPS_URI', value:
params.APPS_URI))
buildParams.add(string(name: 'BUILD_KOGITO_APPS_REF', value:
params.APPS_REF))
buildParams.add(booleanParam(name: 'SKIP_TESTS', value:
params.SKIP_TESTS))
buildParams.add(string(name: 'TESTS_KOGITO_EXAMPLES_URI', value:
params.EXAMPLES_URI))
buildParams.add(string(name: 'TESTS_KOGITO_EXAMPLES_REF', value:
params.EXAMPLES_REF))
+ buildParams.add(string(name: 'UPDATE_KOGITO_VERSION', value:
isRelease() ? getProjectVersion() : ''))
+
buildParams.add(booleanParam(name: 'DEPLOY_IMAGE', value:
isDeployImage()))
buildParams.add(booleanParam(name:
'DEPLOY_IMAGE_USE_OPENSHIFT_REGISTRY', value:
isDeployImageInOpenshiftRegistry()))
buildParams.add(string(name:
'DEPLOY_IMAGE_REGISTRY_USER_CREDENTIALS_ID', value:
getDeployImageRegistryUserCredentialsId()))
diff --git a/.ci/jenkins/dsl/jobs.groovy b/.ci/jenkins/dsl/jobs.groovy
index 61066c66..de7314d3 100644
--- a/.ci/jenkins/dsl/jobs.groovy
+++ b/.ci/jenkins/dsl/jobs.groovy
@@ -177,8 +177,8 @@ void setupBuildImageJob(JobType jobType) {
RELEASE_GPG_SIGN_KEY_CREDS_ID:
Utils.getReleaseGpgSignKeyCredentialsId(this),
RELEASE_GPG_SIGN_PASSPHRASE_CREDS_ID:
Utils.getReleaseGpgSignPassphraseCredentialsId(this),
- RELEASE_SVN_REPOSITORY: Utils.getReleaseSvnCredentialsId(this),
- RELEASE_SVN_CREDS_ID: Utils.getReleaseSvnStagingRepository(this)
+ RELEASE_SVN_REPOSITORY: Utils.getReleaseSvnStagingRepository(this),
+ RELEASE_SVN_CREDS_ID: Utils.getReleaseSvnCredentialsId(this)
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
logRotator {
diff --git a/scripts/common.py b/scripts/common.py
index e6512954..26592b36 100644
--- a/scripts/common.py
+++ b/scripts/common.py
@@ -430,6 +430,19 @@ def update_maven_repo_in_setup_maven(repo_url,
replace_default_repository):
replacement = 'export MAVEN_REPO_URL="{}"'.format(repo_url)
update_in_file(SETUP_MAVEN_SCRIPT, pattern, replacement)
+def update_maven_repos_in_setup_maven(repos_url):
+ """
+ Update maven repositories into setup-maven.sh script
+ :param repos_url: Maven repositories urls
+ """
+ repo_list = repos_url.split(',')
+ print("Set maven repos {} in setup-maven script".format(repo_list))
+ pattern = re.compile(r'(# export MAVEN_REPO_URL=.*)')
+ replacement = f"export MAVEN_REPOS={','.join(['REPO_' + str(i) for i, _ in
enumerate(repo_list)])}\n"
+ for i, value in enumerate(repo_list):
+ replacement += f"export REPO_{i}_MAVEN_REPO_URL={value}\n"
+ update_in_file(SETUP_MAVEN_SCRIPT, pattern, replacement)
+
def update_env_value(env_name, env_value):
"""
Update environment value into the given yaml module/image file
diff --git a/scripts/update-repository.py b/scripts/update-repository.py
index f854b37d..48ad38d5 100644
--- a/scripts/update-repository.py
+++ b/scripts/update-repository.py
@@ -32,6 +32,7 @@ import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Update Maven information in
repo from the given artifact url and '
'version.')
+ parser.add_argument('--repo-urls', dest='repo_urls', help='Defines the
urls of the repositories to setup maven, comma (,) separated')
parser.add_argument('--repo-url', dest='repo_url', help='Defines the url
of the repository to setup into the tests')
parser.add_argument('--replace-default-repo', dest='replace_default_repo',
default=False, action='store_true',
help='Enable if repo-url should replace the default
repository')
@@ -53,6 +54,9 @@ if __name__ == "__main__":
parser.add_argument('--tests-only', dest='tests_only', default=False,
action='store_true', help='Update product modules/images')
args = parser.parse_args()
+ if args.repo_urls:
+ common.update_maven_repos_in_setup_maven(args.repo_urls)
+
if args.repo_url:
common.update_maven_repo_in_build_config(args.repo_url,
args.replace_default_repo)
common.update_maven_repo_in_setup_maven(args.repo_url,
args.replace_default_repo)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]