blob: c82ccc2e8e5a9f8ab855ba7711acf44fffdab785 [file] [log] [blame]
@Library('jenkins-pipeline-shared-libraries')_
def changeAuthor = env.ghprbPullAuthorLogin ?: CHANGE_AUTHOR
def changeBranch = env.ghprbSourceBranch ?: CHANGE_BRANCH
def changeTarget = env.ghprbTargetBranch ?: CHANGE_TARGET
testsFailed = false
pipeline {
agent {
label 'kogito-jenkins-node && !master'
}
tools {
go 'golang-1.19'
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')
timeout(time: 12, unit: 'HOURS') // We give a lot of time to timeout due to the lock on Openshift
}
environment {
OPENSHIFT_INTERNAL_REGISTRY = 'image-registry.openshift-image-registry.svc:5000'
CONTAINER_ENGINE = 'podman'
}
stages {
stage('Setup pipeline') {
steps {
script {
helper = load '.ci/jenkins/scripts/helper.groovy'
helper.initPipeline()
}
}
}
stage('Initialize') {
steps {
script {
clean()
sh ' git config --global user.email "jenkins@kie.com" '
sh ' git config --global user.name "kie user"'
githubscm.checkoutIfExists('kogito-serverless-operator', changeAuthor, changeBranch, 'kiegroup', changeTarget, true, ['token' : 'GITHUB_TOKEN', 'usernamePassword' : 'user-kie-ci10'])
sh "set +x && oc login --token=\$(oc whoami -t) --server=${OPENSHIFT_API} --insecure-skip-tls-verify"
}
}
}
stage('Build Operator') {
steps {
sh "make container-build BUILDER=${CONTAINER_ENGINE} IMG=${getBuiltImage()}"
}
}
stage('Push image to Openshift Registry') {
steps {
sh """
set -x
${CONTAINER_ENGINE} login -u jenkins -p \$(oc whoami -t) --tls-verify=false ${OPENSHIFT_REGISTRY}
${CONTAINER_ENGINE} push --tls-verify=false ${getBuiltImage()}
"""
}
}
stage('Run e2e tests') {
options {
lock("Sonataflow Operator OpenShift tests ${OPENSHIFT_API}")
}
stages {
stage('Running e2e tests') {
options {
timeout(time: 90, unit: 'MINUTES')
}
steps {
script {
try {
sh """
export CLUSTER_PLATFORM=openshift
export OPERATOR_IMAGE_NAME=${getInternalImage()}
make test-e2e
"""
} catch (err) {
testsFailed = true
sh "make undeploy || true"
unstable("Error on e2e testing: ${err}")
} finally {
sh 'oc get pods -A'
}
}
}
post {
always {
archiveArtifacts artifacts: 'test/logs/**/*.log', allowEmptyArchive: true
junit testResults: 'test/logs/**/junit.xml', allowEmptyResults: true
}
}
}
}
}
}
post {
unsuccessful {
script {
pullrequest.postComment(util.getMarkdownTestSummary('Openshift tests', '', "${BUILD_URL}", 'GITHUB'), 'GITHUB_TOKEN')
}
}
cleanup {
script {
clean()
}
}
}
}
void clean() {
helper.cleanGoPath()
util.cleanNode("${CONTAINER_ENGINE}")
}
String getBuiltImage() {
return "${OPENSHIFT_REGISTRY}/openshift/kogito-serverless-operator:${getTag()}"
}
String getInternalImage() {
return "image-registry.openshift-image-registry.svc:5000/openshift/kogito-serverless-operator:${getTag()}"
}
String getTag() {
return "pr-\$(echo \${GIT_COMMIT} | cut -c1-7)"
}