Skip to content

Commit

Permalink
update jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste committed Oct 17, 2023
1 parent 9c6f9fc commit d044e9e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
11 changes: 7 additions & 4 deletions .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pipeline {
sh 'printenv'

dir(getRepoName()) {
githubscm.checkoutIfExists(getRepoName(), getChangeAuthor(), getChangeBranch(), 'apache', getChangeTarget(), true)
// githubscm.checkoutIfExists(getRepoName(), getChangeAuthor(), getChangeBranch(), 'apache', getChangeTarget(), true, credentials = [token: getGitAuthorCredentialsId(), usernamePassword: 'kie-ci'])
// TODO Test pupose
deleteDir()
checkout(githubscm.resolveRepository('kogito-images', 'radtriste', 'fix_pipelines', false))
}
}
}
Expand Down Expand Up @@ -95,15 +98,15 @@ String[] getImages() {
}

String getChangeAuthor() {
return env.ghprbAuthorRepoGitUrl ? util.getGroup(env.ghprbAuthorRepoGitUrl) : (env.ghprbPullAuthorLogin ?: CHANGE_AUTHOR)
return CHANGE_AUTHOR
}

String getChangeBranch() {
return env.ghprbSourceBranch ?: CHANGE_BRANCH
return CHANGE_BRANCH
}

String getChangeTarget() {
return env.ghprbTargetBranch ?: CHANGE_TARGET
return CHANGE_TARGET
}

String getRepoName() {
Expand Down
37 changes: 18 additions & 19 deletions .ci/jenkins/Jenkinsfile.build-image
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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'
Expand All @@ -28,8 +26,6 @@ pipeline {
stage('Initialization') {
steps {
script {
clean()

sh 'printenv'

assert getBuildImageName() : 'Please provide `BUILD_IMAGE_NAME` parameter'
Expand All @@ -49,7 +45,7 @@ pipeline {
// Login to final registry if deploy is needed
if (shouldDeployImage()) {
if (isDeployImageInOpenshiftRegistry()) {
cloud.loginOpenShift(env.OPENSHIFT_API, env.OPENSHIFT_CREDS_KEY)
cloud.loginOpenShift(getOpenShiftAPI(), 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 ?: '')
Expand Down Expand Up @@ -199,24 +195,11 @@ pipeline {
always {
script {
updateGithubCommitStatusFromBuildResult()

clean()
}
}
}
}

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

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

// Clean Cekit cache, in case we reuse an old node
sh "rm -rf \$HOME/.cekit/cache"
}

String getMakeBuildImageArgs() {
List args = []
if (getBuildKogitoAppsRef()) {
Expand Down Expand Up @@ -261,7 +244,7 @@ String getDeployImageRegistryCredentials() {
}

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

String getDeployImageNamespace() {
Expand Down Expand Up @@ -292,6 +275,22 @@ boolean isDeployLatestTag() {
// utils
////////////////////////////////////////////////////////////////////////

String getOpenShiftRegistry() {
String registry = ''
withCredentials([string(credentialsId: 'OPENSHIFT_REGISTRY', variable: 'OPENSHIFT_REGISTRY')]) {
registry = env.OPENSHIFT_REGISTRY
}
return registry
}

String getOpenShiftAPI() {
String openShiftAPI = ''
withCredentials([string(credentialsId: 'OPENSHIFT_API', variable: 'OPENSHIFT_API')]) {
openShiftAPI = env.OPENSHIFT_API
}
return openShiftAPI
}

String getRepoName() {
return env.REPO_NAME
}
Expand Down
18 changes: 6 additions & 12 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ deployProperties = [:]

changesDone = false

BUILT_IMAGES = []
BUILD_FAILED_IMAGES = []
TEST_FAILED_IMAGES = []
BUILT_IMAGES = Collections.synchronizedList([])
BUILD_FAILED_IMAGES = Collections.synchronizedList([])
TEST_FAILED_IMAGES = Collections.synchronizedList([])

pipeline {
agent {
Expand Down Expand Up @@ -304,21 +304,15 @@ void createBuildAndTestStageClosure(String image) {
}

void registerBuiltImage(String imageName) {
lock("${BUILD_URL} build success") {
BUILT_IMAGES.add(imageName)
}
BUILT_IMAGES.add(imageName)
}

void registerBuildFailedImage(String imageName) {
lock("${BUILD_URL} build failed") {
BUILD_FAILED_IMAGES.add(imageName)
}
BUILD_FAILED_IMAGES.add(imageName)
}

void registerTestFailedImage(String imageName) {
lock("${BUILD_URL} test failed") {
TEST_FAILED_IMAGES.add(imageName)
}
TEST_FAILED_IMAGES.add(imageName)
}

List getBuiltImages() {
Expand Down

0 comments on commit d044e9e

Please sign in to comment.