Skip to content

Commit

Permalink
KOGITO-7889 Setup podman nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste committed Sep 12, 2022
1 parent c9cf5ff commit 6057efe
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,4 @@ MavenStagingHelper getStagingHelper() {

String getLocalDeploymentFolder() {
return "${env.MAVEN_DEPLOY_LOCAL_DIR}/${getRepoName()}"
}
}
168 changes: 168 additions & 0 deletions .ci/jenkins/Jenkinsfile.podman
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
@Library('jenkins-pipeline-shared-libraries')_

import org.kie.jenkins.MavenCommand

droolsRepo = 'drools'
kogitoRuntimesRepo = 'kogito-runtimes'

pipeline {
agent {
label 'kie-rhel8 && kie-mem16g && !master'
}
tools {
maven env.BUILD_MAVEN_TOOL
jdk env.BUILD_JDK_TOOL
}
options {
timestamps()
timeout(time: 360, unit: 'MINUTES')
}
environment {
KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")
MAVEN_OPTS = '-Xms1024m -Xmx6g -XX:PermSize=128m -XX:MaxPermSize=512m'
}
stages {
stage('Initialize') {
steps {
script {
checkoutDroolsRepo()
checkoutKogitoRuntimesRepo()
}
}
}

stage('Setup podman env') {
steps {
script {
// Follow instructions from https://quarkus.io/blog/quarkus-devservices-testcontainers-podman/
sh '''
echo "DOCKER_HOST=${DOCKER_HOST}"
'''
sh 'podman version'
sh '''
whereis podman-docker
sudo yum install -y podman-docker podman-remote
whereis podman-docker

systemctl --user enable podman.socket --now

podman-remote info
podman info

docker info
'''

// Create testcontainers properties
// dir(getRepoName()) {
// sh """
// echo 'ryuk.container.privileged=true' > .text
// """
// }
}
}
}

stage('Build Drools') {
steps {
script {
getMavenCommand(droolsRepo)
.withProperty('quickly')
.run('clean install')
}
}
post {
always {
script {
cleanContainers()
}
}
}
}

stage('Build kogito-runtimes') {
steps {
script {
dir('kogito-runtimes') {
sh """
export DOCKER_HOST=unix:///run/user/\${UID}/podman/podman.sock
export TESTCONTAINERS_RYUK_DISABLED=true
${getMavenCommand('kogito-runtimes').withProperty('maven.test.failure.ignore', true).getFullRunCommand('clean install')}
"""
}
}
}
post {
always {
script {
cleanContainers()
}
}
}
}
}
post {
unsuccessful {
sendNotification()
}
always {
script {
junit testResults: '**/target/surefire-reports/**/*.xml, **/target/failsafe-reports/**/*.xml', allowEmptyResults: true
util.archiveConsoleLog()
}
}
cleanup {
script {
util.cleanNode('podman')
}
}
}
}

void sendNotification() {
mailer.sendMarkdownTestSummaryNotification("${NOTIFICATION_JOB_NAME}", "[${params.BUILD_BRANCH_NAME}] Kogito Runtimes", [env.KOGITO_CI_EMAIL_TO])
}

void checkoutKogitoRuntimesRepo() {
dir(kogitoRuntimesRepo) {
checkout(githubscm.resolveRepository(kogitoRuntimesRepo, params.GIT_AUTHOR, getKogitoTargetBranch(), false))
}
}

void checkoutDroolsRepo() {
dir(droolsRepo) {
checkout(githubscm.resolveRepository(droolsRepo, params.GIT_AUTHOR, getDroolsTargetBranch(), false))
}
}

String getKogitoTargetBranch() {
return getTargetBranch(0)
}

String getDroolsTargetBranch() {
return getTargetBranch(7)
}

String getTargetBranch(Integer addToMajor) {
String targetBranch = params.BUILD_BRANCH_NAME
String [] versionSplit = targetBranch.split("\\.")
if (versionSplit.length == 3
&& versionSplit[0].isNumber()
&& versionSplit[1].isNumber()
&& versionSplit[2] == 'x') {
targetBranch = "${Integer.parseInt(versionSplit[0]) + addToMajor}.${versionSplit[1]}.x"
} else {
echo "Cannot parse targetBranch as release branch so going further with current value: ${targetBranch}"
}
return targetBranch
}

MavenCommand getMavenCommand(String directory) {
return new MavenCommand(this, ['-fae', '-ntp'])
.withSettingsXmlId('kogito_release_settings')
.withProperty('java.net.preferIPv4Stack', true)
.inDirectory(directory)
}

void cleanContainers() {
cloud.cleanContainersAndImages('podman')
}
28 changes: 28 additions & 0 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* https://github.com/kiegroup/kogito-pipelines/tree/main/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl.
*/

import org.kie.jenkins.jobdsl.model.Environment
import org.kie.jenkins.jobdsl.model.Folder
import org.kie.jenkins.jobdsl.model.JobType
import org.kie.jenkins.jobdsl.KogitoJobTemplate
import org.kie.jenkins.jobdsl.KogitoJobUtils
import org.kie.jenkins.jobdsl.Utils
Expand Down Expand Up @@ -59,6 +61,7 @@ setupQuarkusJob(Folder.NIGHTLY_QUARKUS_MAIN)
setupQuarkusJob(Folder.NIGHTLY_QUARKUS_BRANCH)
setupQuarkusJob(Folder.NIGHTLY_QUARKUS_LTS)
setupMandrelJob()
setupPodmanJob()

// Release jobs
setupDeployJob(Folder.RELEASE)
Expand Down Expand Up @@ -139,6 +142,31 @@ void setupMandrelJob() {
}
}

void setupPodmanJob() {
Environment podmanEnv = new Environment(
name: 'PODMAN',
optional: true,
)
Folder podmanFolder = new Folder(
name: 'NIGHTLY_PODMAN',
jobType: JobType.NIGHTLY,
environment: podmanEnv,
)
def jobParams = KogitoJobUtils.getBasicJobParams(this, 'kogito-runtimes', podmanFolder, "${jenkins_path}/Jenkinsfile.podman", 'Kogito Runtimes Podman Testing')
KogitoJobUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
jobParams.triggers = [ cron : 'H 8 * * *' ]
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
NOTIFICATION_JOB_NAME: 'Podman check'
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
stringParam('BUILD_BRANCH_NAME', "${GIT_BRANCH}", 'Set the Git branch to checkout')
stringParam('GIT_AUTHOR', "${GIT_AUTHOR_NAME}", 'Set the Git author to checkout')
}
}
}

void setupInitBranchJob() {
def jobParams = KogitoJobUtils.getBasicJobParams(this, 'kogito-runtimes', Folder.INIT_BRANCH, "${jenkins_path}/Jenkinsfile.init-branch", 'Kogito Runtimes Init branch')
KogitoJobUtils.setupJobParamsDefaultMavenConfiguration(this, jobParams)
Expand Down

0 comments on commit 6057efe

Please sign in to comment.