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

KOGITO-9681 CI: Use cloud shared libraries #1669

Closed
Closed
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
32 changes: 12 additions & 20 deletions .ci/jenkins/Jenkinsfile.build-image
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ pipeline {
CONTAINER_ENGINE = 'docker'
CONTAINER_ENGINE_TLS_OPTIONS = ''

OPENSHIFT_API = credentials('OPENSHIFT_API')
OPENSHIFT_REGISTRY = credentials('OPENSHIFT_REGISTRY')
OPENSHIFT_CREDS_KEY = 'OPENSHIFT_CREDS'

IMAGE_BUILD_PLATFORMS = 'linux/amd64,linux/arm64'
}
stages {
Expand Down Expand Up @@ -55,13 +51,8 @@ pipeline {
}

// Login to final registry if deploy is needed
if (shouldDeployImage()) {
if (isDeployImageInOpenshiftRegistry()) {
cloud.loginOpenShift(env.OPENSHIFT_API, env.OPENSHIFT_CREDS_KEY)
cloud.loginOpenshiftRegistry(env.CONTAINER_ENGINE, env.CONTAINER_ENGINE_TLS_OPTIONS ?: '')
} else if (getDeployImageRegistryCredentials()) {
cloud.loginContainerRegistry(getDeployImageRegistry(), getDeployImageRegistryCredentials(), env.CONTAINER_ENGINE, env.CONTAINER_ENGINE_TLS_OPTIONS ?: '')
}
if (shouldDeployImage() && getDeployImageRegistryCredentials()) {
getContainerEngineService().loginContainerRegistry(getDeployImageRegistry(), getDeployImageRegistryCredentials())
}
}
}
Expand Down Expand Up @@ -107,7 +98,7 @@ pipeline {
script {
updateGithubCommitStatus('PENDING', 'Build in progress')

String localRegistry = cloud.startLocalRegistry()
String localRegistry = getContainerEngineService().startLocalRegistry()
cloud.prepareForDockerMultiplatformBuild([localRegistry],[cloud.getDockerIOMirrorRegistryConfig()], false)

// Generate the Dockerfile
Expand Down Expand Up @@ -214,11 +205,16 @@ pipeline {
}
}

ContainerEngineService getContainerEngineService() {
return new ContainerEngineService(this)
}

void clean() {
util.cleanNode(env.CONTAINER_ENGINE)
util.cleanNode()
getContainerEngineService().clean()
getContainerEngineService().cleanLocalRegistry()

cloud.cleanDockerMultiplatformBuild()
cloud.cleanLocalRegistry()
cloud.cleanSkopeo()

// Clean Cekit cache, in case we reuse an old node
Expand Down Expand Up @@ -260,20 +256,16 @@ void runPythonCommand(String cmd, boolean stdout = false) {
// Deploy image information
////////////////////////////////////////////////////////////////////////

boolean isDeployImageInOpenshiftRegistry() {
return params.DEPLOY_IMAGE_USE_OPENSHIFT_REGISTRY
}

String getDeployImageRegistryCredentials() {
return params.DEPLOY_IMAGE_REGISTRY_CREDENTIALS
}

String getDeployImageRegistry() {
return isDeployImageInOpenshiftRegistry() ? env.OPENSHIFT_REGISTRY : params.DEPLOY_IMAGE_REGISTRY
return params.DEPLOY_IMAGE_REGISTRY
}

String getDeployImageNamespace() {
return isDeployImageInOpenshiftRegistry() ? 'openshift' : params.DEPLOY_IMAGE_NAMESPACE
return params.DEPLOY_IMAGE_NAMESPACE
}

String getDeployImageNameSuffix() {
Expand Down
10 changes: 2 additions & 8 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ pipeline {
KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

PR_BRANCH_HASH = "${util.generateHash(10)}"

OPENSHIFT_REGISTRY = credentials('OPENSHIFT_REGISTRY')
}

stages {
Expand Down Expand Up @@ -282,7 +280,6 @@ void createBuildAndTestStageClosure(String image) {
buildParams.add(string(name: 'TESTS_KOGITO_EXAMPLES_REF', value: params.EXAMPLES_REF))

buildParams.add(booleanParam(name: 'DEPLOY_IMAGE', value: true))
buildParams.add(booleanParam(name: 'DEPLOY_IMAGE_USE_OPENSHIFT_REGISTRY', value: isDeployImageInOpenshiftRegistry()))
buildParams.add(string(name: 'DEPLOY_IMAGE_REGISTRY_CREDENTIALS', value: getDeployImageRegistryCredentials()))
buildParams.add(string(name: 'DEPLOY_IMAGE_REGISTRY', value: getDeployImageRegistry()))
buildParams.add(string(name: 'DEPLOY_IMAGE_NAMESPACE', value: getDeployImageNamespace()))
Expand Down Expand Up @@ -341,19 +338,16 @@ List getTestFailedImages() {
// Deploy image information
////////////////////////////////////////////////////////////////////////

boolean isDeployImageInOpenshiftRegistry() {
return params.IMAGE_USE_OPENSHIFT_REGISTRY
}

String getDeployImageRegistryCredentials() {
return params.IMAGE_REGISTRY_CREDENTIALS
}

String getDeployImageRegistry() {
return isDeployImageInOpenshiftRegistry() ? env.OPENSHIFT_REGISTRY : params.IMAGE_REGISTRY
return params.IMAGE_REGISTRY
}
String getDeployImageNamespace() {
return isDeployImageInOpenshiftRegistry() ? 'openshift' : params.IMAGE_NAMESPACE
return params.IMAGE_NAMESPACE
}
String getDeployImageNameSuffix() {
return params.IMAGE_NAME_SUFFIX
Expand Down
Loading
Loading