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#1211: Publish kogito-ci-build image in dockerhub Fix weekly Jenkins job #1208

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .ci/jenkins/Jenkinsfile.build-kogito-ci-image
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pipeline {
environment {
DOCKER_CONFIG = "${WORKSPACE}/.docker"

IMAGE_NAME = 'quay.io/kiegroup/kogito-ci-build'
IMAGE_NAME = 'docker.io/apache/incubator-kie-kogito-ci-build'
IMAGE_TAG = "${BRANCH_NAME}-build-${BUILD_NUMBER}"
IMAGE_NAME_TAG = "${env.IMAGE_NAME}:${env.IMAGE_TAG}"
}
Expand All @@ -29,7 +29,7 @@ pipeline {

currentBuild.displayName = env.IMAGE_TAG

cloud.loginContainerRegistry('quay.io', 'quay_kiegroup_registry_token')
cloud.loginContainerRegistry('docker.io', 'DOCKERHUB_USER', 'DOCKERHUB_TOKEN')

dir('kogito-pipelines') {
deleteDir()
Expand All @@ -54,7 +54,7 @@ pipeline {
always {
script {
sh "rm -rf ${DOCKER_CONFIG}"
sh 'docker logout quay.io'
sh 'docker logout docker.io'
}
}
}
Expand Down
25 changes: 14 additions & 11 deletions jenkins-pipeline-shared-libraries/test/vars/CloudSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -818,25 +818,29 @@ http = false
def "[cloud.groovy] loginContainerRegistry default"() {
setup:
groovyScript.getBinding().setVariable("REGISTRY_USER", 'user')
groovyScript.getBinding().setVariable("REGISTRY_PWD", 'password')
groovyScript.getBinding().setVariable("REGISTRY_TOKEN", 'password')
when:
groovyScript.loginContainerRegistry('REGISTRY', 'REGISTRY_CREDS_ID')
groovyScript.loginContainerRegistry('REGISTRY', 'REGISTRY_USER_CREDS_ID', 'REGISTRY_TOKEN_CREDS_ID')
then:
1 * getPipelineMock('usernamePassword.call')([credentialsId: 'REGISTRY_CREDS_ID', usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PWD']) >> 'userNamePassword'
1 * getPipelineMock("withCredentials")(['userNamePassword'], _ as Closure)
1 * getPipelineMock("sh")("set +x && docker login -u user -p password REGISTRY")
1 * getPipelineMock('string.call')([credentialsId: 'REGISTRY_USER_CREDS_ID', variable: 'REGISTRY_USER']) >> 'user'
1 * getPipelineMock("withCredentials")(['user'], _ as Closure)
1 * getPipelineMock('string.call')([credentialsId: 'REGISTRY_TOKEN_CREDS_ID', variable: 'REGISTRY_TOKEN']) >> 'token'
1 * getPipelineMock("withCredentials")(['token'], _ as Closure)
1 * getPipelineMock("sh")("echo \"password\" | docker login -u \"user\" --password-stdin REGISTRY")
}

def "[cloud.groovy] loginContainerRegistry with container engine and options"() {
setup:
groovyScript.getBinding().setVariable("REGISTRY_USER", 'user')
groovyScript.getBinding().setVariable("REGISTRY_PWD", 'password')
groovyScript.getBinding().setVariable("REGISTRY_TOKEN", 'password')
when:
groovyScript.loginContainerRegistry('REGISTRY', 'REGISTRY_CREDS_ID', 'podman', '--tls-verify=false')
groovyScript.loginContainerRegistry('REGISTRY', 'REGISTRY_USER_CREDS_ID', 'REGISTRY_TOKEN_CREDS_ID', 'podman', '--tls-verify=false')
then:
1 * getPipelineMock('usernamePassword.call')([credentialsId: 'REGISTRY_CREDS_ID', usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PWD']) >> 'userNamePassword'
1 * getPipelineMock("withCredentials")(['userNamePassword'], _ as Closure)
1 * getPipelineMock("sh")("set +x && podman login -u user -p password --tls-verify=false REGISTRY")
1 * getPipelineMock('string.call')([credentialsId: 'REGISTRY_USER_CREDS_ID', variable: 'REGISTRY_USER']) >> 'user'
1 * getPipelineMock("withCredentials")(['user'], _ as Closure)
1 * getPipelineMock('string.call')([credentialsId: 'REGISTRY_TOKEN_CREDS_ID', variable: 'REGISTRY_TOKEN']) >> 'token'
1 * getPipelineMock("withCredentials")(['token'], _ as Closure)
1 * getPipelineMock("sh")("echo \"password\" | podman login -u \"user\" --password-stdin --tls-verify=false REGISTRY")
}

/////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -951,4 +955,3 @@ http = false
1 * getPipelineMock('sh')([script: "curl -H 'Content-type: application/json' -H 'Authorization: Bearer quaytoken' -X PUT --data-binary '@description.json' https://quay.io/api/v1/repository/namespace/repository"])
}
}

10 changes: 7 additions & 3 deletions jenkins-pipeline-shared-libraries/vars/cloud.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ String getOpenShiftRegistryURL() {
/*
* Login to a container registry
*/
void loginContainerRegistry(String registry, String credsId, String containerEngine = 'docker', String containerEngineTlsOptions = '') {
withCredentials([usernamePassword(credentialsId: credsId, usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PWD')]) {
sh "set +x && ${containerEngine} login -u ${REGISTRY_USER} -p ${REGISTRY_PWD} ${containerEngineTlsOptions} ${registry}"
void loginContainerRegistry(String registry, String userCredsId, String tokenCredsId, String containerEngine = 'docker', String containerEngineTlsOptions = '') {
withCredentials([string(credentialsId: userCredsId, variable: 'REGISTRY_USER')]) {
withCredentials([string(credentialsId: tokenCredsId, variable: 'REGISTRY_TOKEN')]) {
sh """
echo "${REGISTRY_TOKEN}" | ${containerEngine} login -u "${REGISTRY_USER}" --password-stdin ${containerEngineTlsOptions} ${registry}
""".trim()
}
}
}

Expand Down
Loading