Skip to content

Commit

Permalink
[SRVLOGIC-286] add Operator image as part of OSL productized nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
rgdoliveira committed Jul 19, 2024
1 parent 093f938 commit 32652c0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
56 changes: 54 additions & 2 deletions .ci/jenkins/Jenkinsfile.prod.nightly
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pipeline {
env.ARTIFACTS_VERSION = "${env.PRODUCT_VERSION}.redhat-${env.DATE_TIME_SUFFIX}"
env.M2_FOLDER = '/home/jenkins/.m2/repository'
env.IMAGES_REPOSITORY_PATH = "${env.WORKSPACE}/bc/kiegroup_kogito-images"
env.OPERATOR_REPOSITORY_PATH = "${env.WORKSPACE}/bc/kiegroup_kogito-serverless-operator"
env.SLEEP_TIME = '30' // required as cekit-cache command fails if many invocations at the same time

// Images names
Expand All @@ -108,6 +109,7 @@ pipeline {
env.JOBS_SERVICE_POSTGRESQL = 'jobs-service-postgresql'
env.SWF_BUILDER = 'swf-builder'
env.SWF_DEVMODE = 'swf-devmode'
env.OPERATOR = 'operator'

// Images registries placeholders
env.DATA_INDEX_EPHEMERAL_REGISTRY = ''
Expand All @@ -116,6 +118,7 @@ pipeline {
env.JOBS_SERVICE_POSTGRESQL_REGISTRY = ''
env.SWF_BUILDER_REGISTRY = ''
env.SWF_DEVMODE_REGISTRY = ''
env.OPERATOR_REGISTRY = ''
}
}
}
Expand Down Expand Up @@ -206,6 +209,17 @@ pipeline {
}
}
}
stage('Operator image') {
steps {
script {
sleep(Integer.parseInt(env.SLEEP_TIME) * 6)

def descriptorFile = 'images/prod-operator-image.yaml'
env.OPERATOR_REGISTRY = buildOperator(descriptorFile, env.NIGHTLY_BRANCH_NAME, env.OPERATOR_REPOSITORY_PATH)
}
}
}

}
}
stage('Upload maven repository') {
Expand Down Expand Up @@ -244,7 +258,9 @@ pipeline {
def sanitizedProjectName = f.replaceAll('/', '_').replaceAll('-', '_')
def buildScript = env["PME_BUILD_SCRIPT_${sanitizedProjectName}"]
def pomPath = maven.getProjectPomFromBuildCmd(buildScript)
env["VERSION_${f}"] = maven.mvnGetVersionProperty(new MavenCommand(this).withProperty('productized'), 'project.version', pomPath)
if (new File(pomPath).exists()) {
env["VERSION_${f}"] = maven.mvnGetVersionProperty(new MavenCommand(this).withProperty('productized'), 'project.version', pomPath)
}
}
}

Expand All @@ -265,7 +281,7 @@ pipeline {
env.ALREADY_BUILT_PROJECTS,
['serverlesslogic': env['VERSION_kiegroup_kogito-runtimes'], 'serverlesslogic-rhba': env['VERSION_kiegroup_kogito-runtimes'], 'drools': env.VERSION_kiegroup_drools, 'platform.quarkus.bom': env.QUARKUS_PLATFORM_VERSION, 'quarkus.bom': env.QUARKUS_VERSION],
["${env.DATA_INDEX_EPHEMERAL}": env.DATA_INDEX_EPHEMERAL_REGISTRY, "${env.DATA_INDEX_POSTGRESQL}": env.DATA_INDEX_POSTGRESQL_REGISTRY, "${env.JOBS_SERVICE_EPHEMERAL}": env.JOBS_SERVICE_EPHEMERAL_REGISTRY, "${JOBS_SERVICE_POSTGRESQL}": env.JOBS_SERVICE_POSTGRESQL_REGISTRY,
"${env.SWF_BUILDER}": env.SWF_BUILDER_REGISTRY, "${env.SWF_DEVMODE}": env.SWF_DEVMODE_REGISTRY],
"${env.SWF_BUILDER}": env.SWF_BUILDER_REGISTRY, "${env.SWF_DEVMODE}": env.SWF_DEVMODE_REGISTRY, "${env.OPERATOR}": env.OPERATOR_REGISTRY],
gitHashesToCollection(env.GIT_INFORMATION_HASHES)
)
echo "[INFO] Message Body: ${messageBody}"
Expand Down Expand Up @@ -310,6 +326,42 @@ pipeline {
}
}

def buildOperator(String descriptorFile, String nightlyBranchName, String operatorRepository) {
// Create a different folder for operator, otherwise dir() will mess up with folders and impact other steps of pipeline
sh "cp -rp ${operatorRepository} ${env.WORKSPACE}/operator_repo"
dir("${env.WORKSPACE}/operator_repo") {
println "Building operator"

// Remove go work files due to cachito limitation and push changes to a temporary prod branch
def prodBranch = "main-prod-nightly"
if (githubscm.isBranchExist("origin", prodBranch)) {
githubscm.removeRemoteBranch("origin", prodBranch)
}
githubscm.createBranch(prodBranch)
sh "rm -f go.work go.work.sum"
githubscm.commitChanges("remove go work files due to cachito limitation")
githubscm.pushObject("origin", prodBranch)

// Replace branch and ref in descriptor file
sh """sed -i "s/branch:.*/branch: ${nightlyBranchName}/g" ${descriptorFile}"""
def reference = githubscm.getCommitHash()
sh """sed -i "s/ref:.*/ref: ${reference}/g" ${descriptorFile}"""
println "Diff of ${descriptorFile} after replacing branch name and ref"
sh "git diff ${descriptorFile}"

println 'Using cekit version'
util.runWithPythonVirtualEnv('cekit --version', 'cekit')

util.withKerberos('rhba-osbs-builder-keytab') {
def cekitBuildCmd = "cekit --redhat --descriptor ${descriptorFile} build osbs --user rhba-osbs-builder -y"
util.runWithPythonVirtualEnv("${cekitBuildCmd} | tee operator-build-log.txt", 'cekit')
}

def imageRegistry = sh(script: "brew call --json-output getTaskResult \$(cat operator-build-log.txt | grep -oP '(?<=Task ).*(?= was)') | jq -nre 'input.repositories[0]'", returnStdout: true)
return imageRegistry.trim()
}
}

def buildImage(String imageName, String descriptorFile, String nightlyBranchName, Map<String, String> artifacts, String imagesRepository) {
// Create a different folder for each image during the build, otherwise dir() will mess up the builds during parallel run
sh "cp -rp ${imagesRepository} ${env.WORKSPACE}/${imageName}_repo"
Expand Down
7 changes: 6 additions & 1 deletion .ci/nightly-build-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ build:
export NIGHTLY_DEPLOY_FOLDER="${{ env.WORKSPACE }}/deployDirectory"
echo "NIGHTLY_DEPLOY_FOLDER=${{ env.NIGHTLY_DEPLOY_FOLDER }}"
${{ env.PME_CMD }} ${{ env.PME_ALIGNMENT_PARAMS_kiegroup_kogito_images }}
bash -c "set -o pipefail ; ${{ env.PME_BUILD_SCRIPT_kiegroup_kogito_images }} ${{ env.BUILD_MVN_OPTS }} | tee ${{ env.WORKSPACE }}/kogito_images.maven.log"
bash -c "set -o pipefail ; ${{ env.PME_BUILD_SCRIPT_kiegroup_kogito_images }} ${{ env.BUILD_MVN_OPTS }} | tee ${{ env.WORKSPACE }}/kogito_images.maven.log"
- project: kiegroup/kogito-serverless-operator
build-command:
downstream: |
echo "Cloned operator repository for building Operator image"
4 changes: 4 additions & 0 deletions .ci/nightly-project-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ dependencies:
- project: kiegroup/kogito-images
dependencies:
- project: kiegroup/kie-tools

- project: kiegroup/kogito-serverless-operator
dependencies:
- project: kiegroup/kogito-images

0 comments on commit 32652c0

Please sign in to comment.