Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kie-issues#1214: Replace explicit references to quay.io images across CI pipelines #1772

Merged
merged 5 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions .ci/jenkins/Jenkinsfile.build-image
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
*/
@Library('jenkins-pipeline-shared-libraries')_

QUAY_REGISTRY = 'quay.io'

pipeline {
agent {
docker {
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
label util.avoidFaultyNodes()
Expand Down Expand Up @@ -149,18 +147,6 @@ pipeline {
}
steps {
script {
// Make public if quay registry
if (getDeployImageRegistry() == QUAY_REGISTRY) {
String namespace = getDeployImageNamespace()
String repository = getFinalImageName()
echo "Check and set public if needed Quay repository ${namespace}/${repository}"
try {
cloud.makeQuayImagePublic(namespace, repository, [ usernamePassword: getDeployImageRegistryCredentials()])
} catch (err) {
echo "[ERROR] Cannot set image quay.io/${namespace}/${repository} as visible"
}
}

int retries = Integer.parseInt(env.MAX_REGISTRY_RETRIES)
String imageTag = getBuiltImageTag()
if (isDeployLatestTag()) {
Expand Down Expand Up @@ -228,15 +214,15 @@ pipeline {
}
steps {
script {
def resultingFileName = "${getFinalImageName()}.tar.gz"
def resultingFileName = "incubator-kie-${getImageArtifactReleaseVersion()}-${getBuildImageName()}.tar.gz"
def signatureFileName = "${resultingFileName}.asc"
sh """
docker pull ${getBuiltImageTag()}
docker save ${getBuiltImageTag()} | gzip > ${resultingFileName}
"""
release.gpgImportKeyFromFileWithPassword(getReleaseGpgSignKeyCredsId(), getReleaseGpgSignPassphraseCredsId())
release.gpgSignFileDetachedSignatureWithPassword(resultingFileName, signatureFileName, getReleaseGpgSignPassphraseCredsId())
release.svnUploadFileToRepository(getReleaseSvnRepository(), getReleaseSvnCredsId(), getReleaseVersion(), resultingFileName, signatureFileName)
release.svnUploadFileToRepository(getReleaseSvnRepository(), getReleaseSvnCredsId(), getImageArtifactReleaseVersion(), resultingFileName, signatureFileName)
}
}
post {
Expand Down Expand Up @@ -328,9 +314,8 @@ String getDeployImageNameSuffix() {
String getDeployImageTag() {
if (params.DEPLOY_IMAGE_TAG != '') {
return params.DEPLOY_IMAGE_TAG
} else {
return sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
}
return sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
}

String getFinalImageName() {
Expand Down Expand Up @@ -471,3 +456,7 @@ String getReleaseSvnRepository() {
String getReleaseSvnCredsId() {
return env.RELEASE_SVN_CREDS_ID
}

String getImageArtifactReleaseVersion() {
return env.IMAGE_ARTIFACT_RELEASE_VERSION
}
14 changes: 13 additions & 1 deletion .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ pipeline {
}
String prLink = githubscm.createPR(commitMsg, prBody, getBuildBranch(), getGitAuthorPushCredsId())
deployProperties["${getRepoName()}.pr.link"] = prLink

// Create a new tag
githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.tagRepository(getGitTagName())
githubscm.pushRemoteTag('origin', getGitTagName(), getGitAuthorPushCredsId())
}
}
}
Expand All @@ -223,10 +228,12 @@ pipeline {
setDeployPropertyIfNeeded("${getRepoName()}.pr.source.ref", getPRBranch())
setDeployPropertyIfNeeded("${getRepoName()}.pr.target.uri", "https://github.com/${getGitAuthor()}/${getRepoName()}")
setDeployPropertyIfNeeded("${getRepoName()}.pr.target.ref", getBuildBranch())
setDeployPropertyIfNeeded("${getRepoName()}.tag.name", getGitTagName())
}
}
}
}

stage('Finalize') {
steps {
script {
Expand Down Expand Up @@ -308,6 +315,7 @@ void createBuildAndTestStageClosure(String image) {
buildParams.add(string(name: 'DEPLOY_IMAGE_NAME_SUFFIX', value: getDeployImageNameSuffix()))
buildParams.add(string(name: 'DEPLOY_IMAGE_TAG', value: getDeployImageTag()))
buildParams.add(booleanParam(name: 'DEPLOY_WITH_LATEST_TAG', value: isDeployLatestTag()))
buildParams.add(string(name: 'IMAGE_ARTIFACT_RELEASE_VERSION', value: getGitTagName()))

def job = build(job: 'kogito-images.build-image', wait: true, parameters: buildParams, propagate: false)
if (job.result != 'SUCCESS') {
Expand Down Expand Up @@ -450,4 +458,8 @@ String[] getImages() {

String getQuarkusPlatformVersion() {
return params.QUARKUS_PLATFORM_VERSION
}
}

String getGitTagName() {
return params.GIT_TAG_NAME
}
18 changes: 0 additions & 18 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,6 @@ void promoteImage(String oldImageName, String newImageName) {
cloud.skopeoCopyRegistryImages(oldImageName, newImageName, Integer.parseInt(env.MAX_REGISTRY_RETRIES))
}

// Set images public on quay. Useful when new images are introduced.
void makeQuayNewImagesPublic() {
String namespace = getNewImageNamespace()
for (String imageName : getImages()) {
String repository = getFinalImageName(imageName, getNewImageNameSuffix())
echo "Check and set public if needed Quay repository ${namespace}/${repository}"
try {
cloud.makeQuayImagePublic(namespace, repository, [ usernamePassword: getNewImageRegistryCredentials()])
} catch (err) {
echo "[ERROR] Cannot set image quay.io/${namespace}/${repository} as visible"
}
}
}

String getOldImageFullTag(String imageName) {
return "${getOldImageRegistry()}/${getOldImageNamespace()}/${getFinalImageName(imageName, getOldImageNameSuffix())}:${getOldImageTag()}"
}
Expand Down Expand Up @@ -296,10 +282,6 @@ String getGitAuthorPushCredsId() {
return env.GIT_AUTHOR_PUSH_CREDS_ID
}

boolean isQuayRegistry(String registry) {
return registry == 'quay.io'
}

////////////////////////////////////////////////////////////////////////
// Old image information
////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void setupDeployJob(JobType jobType) {
stringParam('KOGITO_ARTIFACTS_VERSION', '', 'Optional. If artifacts\' version is different from PROJECT_VERSION.')
if (jobType == JobType.RELEASE) {
stringParam('QUARKUS_PLATFORM_VERSION', '', 'Allow to override the Quarkus Platform version')
stringParam('GIT_TAG_NAME', '', 'Git tag to be created')
}

stringParam('KOGITO_PR_BRANCH', '', 'PR branch name')
Expand Down Expand Up @@ -210,6 +211,7 @@ void setupBuildImageJob(JobType jobType) {
stringParam('DEPLOY_IMAGE_TAG', '', 'Image tag to use to deploy images')
booleanParam('DEPLOY_WITH_LATEST_TAG', false, 'Set to true if you want the deployed images to also be with the `latest` tag')
booleanParam('EXPORT_AND_GPG_SIGN_IMAGE', jobType == JobType.RELEASE, 'Set to true if should images be exported and signed.')
stringParam('IMAGE_ARTIFACT_RELEASE_VERSION', '', 'Set the release version to be attached to the images artifacts names')
}
}
}
Expand Down
Loading