Skip to content

Commit

Permalink
Use the new dockerhub credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigonull committed Jun 25, 2024
1 parent 3cee911 commit ece88e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ void setupDeployJob(JobType jobType, String envName = '') {
stringParam('QUICKSTARTS_BUILD_BRANCH_NAME', Utils.isMainBranch(this) ? 'development' : "${GIT_BRANCH}", 'Base branch for quickstarts. Set if you are not on a multibranch pipeline.')

stringParam('OPERATOR_IMAGE_REGISTRY', "${CLOUD_IMAGE_REGISTRY}", 'Image registry to use to deploy images.')
stringParam('OPERATOR_IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS}", 'Image registry credentials.')
stringParam('OPERATOR_IMAGE_REGISTRY_USER_CREDENTIALS_ID', "${CLOUD_IMAGE_REGISTRY_USER_CREDENTIALS_ID}", 'Image registry user credentials id.')
stringParam('OPERATOR_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID', "${CLOUD_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID}", 'Image registry token credentials id.')
stringParam('OPERATOR_IMAGE_NAMESPACE', "${CLOUD_IMAGE_NAMESPACE}", 'Operator image namespace to use to deploy image.')
stringParam('OPERATOR_IMAGE_TAG', '', 'Image tag to use to deploy the operator image. OptaPlanner project version if not set.')
}
Expand Down Expand Up @@ -393,7 +394,8 @@ void setupPromoteJob(JobType jobType) {
booleanParam('SEND_NOTIFICATION', false, 'In case you want the pipeline to send a notification on CI channel for this run.')

stringParam('OPERATOR_IMAGE_REGISTRY', "${CLOUD_IMAGE_REGISTRY}", 'Image registry to use to deploy images.')
stringParam('OPERATOR_IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS}", 'Image registry credentials.')
stringParam('OPERATOR_IMAGE_REGISTRY_USER_CREDENTIALS_ID', "${CLOUD_IMAGE_REGISTRY_USER_CREDENTIALS_ID}", 'Image registry user credentials id.')
stringParam('OPERATOR_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID', "${CLOUD_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID}", 'Image registry token credentials id.')
stringParam('OPERATOR_IMAGE_NAMESPACE', "${CLOUD_IMAGE_NAMESPACE}", 'Operator image namespace to use to deploy image.')
}
}
Expand Down
21 changes: 14 additions & 7 deletions .ci/jenkins/scripts/imageUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@ containerEngine = 'docker'
containerTlsOptions = ''

void loginRegistry() {
loginContainerRegistry(getOperatorImageRegistry(), getOperatorImageRegistryCredentials())
loginContainerRegistry(getOperatorImageRegistry(), getOperatorImageRegistryUserCredentialsId(), getOperatorImageRegistryTokenCredentialsId())
}

void loginContainerRegistry(String registry, String credsId) {
echo "Using credentials ($credsId) to login to registry ($registry)"
withCredentials([usernamePassword(credentialsId: credsId, usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PWD')]) {
sh "${containerEngine} login ${containerTlsOptions} -u ${REGISTRY_USER} -p ${REGISTRY_PWD} ${registry}"
void loginContainerRegistry(String registry, String userCredsId, String tokenCredsId) {
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 ${registry}
""".trim()
}
}
}

String getOperatorImageRegistryCredentials() {
return params.OPERATOR_IMAGE_REGISTRY_CREDENTIALS
String getOperatorImageRegistryUserCredentialsId() {
return params.OPERATOR_IMAGE_REGISTRY_USER_CREDENTIALS_ID
}

String getOperatorImageRegistryTokenCredentialsId() {
return params.OPERATOR_IMAGE_REGISTRY_TOKEN_CREDENTIALS_ID
}

String getOperatorImageRegistry() {
Expand Down

0 comments on commit ece88e5

Please sign in to comment.