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

kie-issues#574 Initial ASF Jenkins CI Setup #257

Merged
merged 1 commit into from
Sep 19, 2023
Merged
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
12 changes: 5 additions & 7 deletions .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ testsFailed = false

pipeline {
agent {
label 'kogito-jenkins-node && !master'
}
tools {
go 'golang-1.19'
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}
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') {
Expand All @@ -39,7 +37,7 @@ pipeline {
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'])
githubscm.checkoutIfExists('incubator-kie-kogito-serverless-operator', changeAuthor, changeBranch, 'apache', 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"
}
Expand Down
20 changes: 8 additions & 12 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,20 @@ commitDone = false

pipeline {
agent {
label 'kie-rhel8 && docker && kie-mem16g && !built-in'
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}

options {
timeout(time: 10, unit: 'HOURS')
timestamps()
}

tools {
go 'golang-1.19'
}

environment {
KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

// Linked to node label
// Use docker due to multiplatform build
CONTAINER_ENGINE = 'docker'
CONTAINER_ENGINE_TLS_OPTIONS = ''

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

IMAGE_BUILD_PLATFORMS = 'linux/amd64,linux/arm64'
Expand Down Expand Up @@ -61,6 +55,8 @@ pipeline {

// Prepare for multiplatform build
String localRegistry = cloud.startLocalRegistry()

// TODO docker buildx could be preinstalled onto the docker image
cloud.prepareForDockerMultiplatformBuild([localRegistry],[cloud.getDockerIOMirrorRegistryConfig()], false)
cloud.installSkopeo()
}
Expand Down Expand Up @@ -277,8 +273,8 @@ String getTempBuiltImageTag() {
return "localhost:5000/kogito-serverless-operator:${getOperatorVersion()}"
}

def runPythonCommand(String cmd, boolean stdout = false) {
return util.runWithPythonVirtualEnv(cmd, 'cekit', stdout)
void runPythonCommand(String cmd, boolean stdout = false) {
return sh(returnStdout: stdout, script: cmd)
}

void pushFinalImage(String oldImageName, String newImageName) {
Expand Down
15 changes: 4 additions & 11 deletions .ci/jenkins/Jenkinsfile.e2e.cluster
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@ openshiftClusterPlatform = 'openshift'

pipeline {
agent {
label "${env.AGENT_LABEL ?: "rhel8"} && podman && !built-in"
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}

options {
timeout(time: 3, unit: 'HOURS')
timestamps()
}

tools {
go 'golang-1.19'
}

environment {
// Linked to node label
CONTAINER_ENGINE='podman'
CONTAINER_ENGINE_TLS_OPTIONS='--tls-verify=false'
}

stages {
stage('Setup pipeline') {
steps {
Expand Down
16 changes: 5 additions & 11 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,21 @@ helper = null

pipeline {
agent {
label 'kie-rhel8 && podman && !built-in'
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}

options {
timeout(time: 120, unit: 'MINUTES')
timestamps()
}

tools {
go 'golang-1.19'
}

environment {
KOGITO_CI_EMAIL_TO = credentials("${JENKINS_EMAIL_CREDS_ID}")

// Linked to node label
CONTAINER_ENGINE = 'podman'
CONTAINER_ENGINE_TLS_OPTIONS = '--tls-verify=false'

PR_BRANCH_HASH = "${util.generateHash(10)}"
GITHUB_REPO = "${REPO_NAME}" // for github-release cli
}

stages {
Expand Down Expand Up @@ -167,7 +161,7 @@ void promoteImage(String oldImageName, String newImageName) {

void updateInternalGoModuleWithTag(String moduleName, String tagName) {
sh """
go get github.com/kiegroup/kogito-serverless-operator/${moduleName}@${githubscm.getTagCommitHash(tagName)}
go get github.com/apache/incubator-kie-kogito-serverless-operator/${moduleName}@${githubscm.getTagCommitHash(tagName)}
go mod tidy
"""
}
Expand Down
9 changes: 4 additions & 5 deletions .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ testsFailed = false

pipeline {
agent {
label 'rhel8 && !built-in'
}

tools {
go 'golang-1.19'
docker {
image env.AGENT_DOCKER_BUILDER_IMAGE
args env.AGENT_DOCKER_BUILDER_ARGS
}
}

options {
Expand Down
16 changes: 9 additions & 7 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* This file is describing all the Jenkins jobs in the DSL format (see https://plugins.jenkins.io/job-dsl/)
* needed by the Kogito pipelines.
*
* The main part of Jenkins job generation is defined into the https://github.com/kiegroup/kogito-pipelines repository.
* The main part of Jenkins job generation is defined into the https://github.com/apache/incubator-kie-kogito-pipelines repository.
*
* This file is making use of shared libraries defined in
* https://github.com/kiegroup/kogito-pipelines/tree/main/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl.
* https://github.com/apache/incubator-kie-kogito-pipelines/tree/main/dsl/seed/src/main/groovy/org/kie/jenkins/jobdsl.
*/

import org.kie.jenkins.jobdsl.model.JobType
Expand All @@ -16,7 +16,6 @@ import org.kie.jenkins.jobdsl.Utils
jenkins_path = '.ci/jenkins'
clustersConfig = [
minikube: [
AGENT_LABEL: 'kie-rhel8 && kie-mem16g',
MINIKUBE_VERSION: '1.30.1',
KUBERNETES_VERSION: '1.26.3',
],
Expand All @@ -42,9 +41,9 @@ setupPromoteJob(JobType.RELEASE)

void createSetupBranchJob() {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-serverless-operator', JobType.SETUP_BRANCH, "${jenkins_path}/Jenkinsfile.setup-branch", 'Kogito Serverless Cloud Operator Setup Branch')
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
REPO_NAME: 'kogito-serverless-operator',

GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
Expand All @@ -67,6 +66,7 @@ void createSetupBranchJob() {

void setupDeployJob(JobType jobType) {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-serverless-operator-deploy', jobType, "${jenkins_path}/Jenkinsfile.deploy", 'Kogito Serverless Cloud Operator Deploy')
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",

Expand Down Expand Up @@ -95,7 +95,7 @@ void setupDeployJob(JobType jobType) {

// Deploy information
booleanParam('IMAGE_USE_OPENSHIFT_REGISTRY', false, 'Set to true if image should be deployed in Openshift registry.In this case, IMAGE_REGISTRY_CREDENTIALS, IMAGE_REGISTRY and IMAGE_NAMESPACE parameters will be ignored')
stringParam('IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS_NIGHTLY}", 'Image registry credentials to use to deploy images. Will be ignored if no IMAGE_REGISTRY is given')
stringParam('IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS}", 'Image registry credentials to use to deploy images. Will be ignored if no IMAGE_REGISTRY is given')
stringParam('IMAGE_REGISTRY', "${CLOUD_IMAGE_REGISTRY}", 'Image registry to use to deploy images')
stringParam('IMAGE_NAMESPACE', "${CLOUD_IMAGE_NAMESPACE}", 'Image namespace to use to deploy images')
stringParam('IMAGE_NAME_SUFFIX', '', 'Image name suffix to use to deploy images. In case you need to change the final image name, you can add a suffix to it.')
Expand All @@ -115,6 +115,7 @@ void setupDeployJob(JobType jobType) {

void setupPromoteJob(JobType jobType) {
def jobParams = JobParamsUtils.getBasicJobParams(this, 'kogito-serverless-operator-promote', jobType, "${jenkins_path}/Jenkinsfile.promote", 'Kogito Serverless Cloud Operator Promote')
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
MAX_REGISTRY_RETRIES: 3,
Expand All @@ -136,15 +137,15 @@ void setupPromoteJob(JobType jobType) {

// Base information which can override `deployment.properties`
booleanParam('BASE_IMAGE_USE_OPENSHIFT_REGISTRY', false, 'Override `deployment.properties`. Set to true if base image should be deployed in Openshift registry.In this case, BASE_IMAGE_REGISTRY_CREDENTIALS, BASE_IMAGE_REGISTRY and BASE_IMAGE_NAMESPACE parameters will be ignored')
stringParam('BASE_IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS_NIGHTLY}", 'Override `deployment.properties`. Base Image registry credentials to use to deploy images. Will be ignored if no BASE_IMAGE_REGISTRY is given')
stringParam('BASE_IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS}", 'Override `deployment.properties`. Base Image registry credentials to use to deploy images. Will be ignored if no BASE_IMAGE_REGISTRY is given')
stringParam('BASE_IMAGE_REGISTRY', "${CLOUD_IMAGE_REGISTRY}", 'Override `deployment.properties`. Base image registry')
stringParam('BASE_IMAGE_NAMESPACE', "${CLOUD_IMAGE_NAMESPACE}", 'Override `deployment.properties`. Base image namespace')
stringParam('BASE_IMAGE_NAME_SUFFIX', '', 'Override `deployment.properties`. Base image name suffix')
stringParam('BASE_IMAGE_TAG', '', 'Override `deployment.properties`. Base image tag')

// Promote information
booleanParam('PROMOTE_IMAGE_USE_OPENSHIFT_REGISTRY', false, 'Set to true if base image should be deployed in Openshift registry.In this case, PROMOTE_IMAGE_REGISTRY_CREDENTIALS, PROMOTE_IMAGE_REGISTRY and PROMOTE_IMAGE_NAMESPACE parameters will be ignored')
stringParam('PROMOTE_IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS_NIGHTLY}", 'Promote Image registry credentials to use to deploy images. Will be ignored if no PROMOTE_IMAGE_REGISTRY is given')
stringParam('PROMOTE_IMAGE_REGISTRY_CREDENTIALS', "${CLOUD_IMAGE_REGISTRY_CREDENTIALS}", 'Promote Image registry credentials to use to deploy images. Will be ignored if no PROMOTE_IMAGE_REGISTRY is given')
stringParam('PROMOTE_IMAGE_REGISTRY', "${CLOUD_IMAGE_REGISTRY}", 'Promote image registry')
stringParam('PROMOTE_IMAGE_NAMESPACE', "${CLOUD_IMAGE_NAMESPACE}", 'Promote image namespace')
stringParam('PROMOTE_IMAGE_NAME_SUFFIX', '', 'Promote image name suffix')
Expand All @@ -162,6 +163,7 @@ void setupPromoteJob(JobType jobType) {

void setupE2EJob(JobType jobType, String clusterName, Map extraEnv = [:]) {
def jobParams = JobParamsUtils.getBasicJobParams(this, "kogito-serverless-operator.e2e.${clusterName}", jobType, "${jenkins_path}/Jenkinsfile.e2e.cluster", 'Kogito Serverless Cloud Operator Deploy')
JobParamsUtils.setupJobParamsAgentDockerBuilderImageConfiguration(this, jobParams)
jobParams.env.putAll([
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",
CLUSTER_NAME: clusterName,
Expand Down
2 changes: 1 addition & 1 deletion .ci/jenkins/dsl/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e
file=$(mktemp)
# For more usage of the script, use ./test.sh -h
curl -o ${file} https://raw.githubusercontent.com/kiegroup/kogito-pipelines/main/dsl/seed/scripts/seed_test.sh
curl -o ${file} https://raw.githubusercontent.com/apache/incubator-kie-kogito-pipelines/main/dsl/seed/scripts/seed_test.sh
chmod u+x ${file}
${file} $@
2 changes: 1 addition & 1 deletion .ci/jenkins/scripts/minikube.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
minikubeVersion = env.MINIKUBE_VERSION ?: '1.30.1'
minikubeKubernetesVersion = env.KUBERNETES_VERSION ?: '1.26.3'
minikubeContainerEngine = env.CONTAINER_ENGINE ?: 'podman'
minikubeContainerEngine = env.CONTAINER_ENGINE ?: 'docker'

minikubeCpus = 'max'
minikubeMemory = '4g'
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: GitHub Issues
url: https://github.com/kiegroup/kogito-serverless-operator/issues
url: https://github.com/apache/incubator-kie-kogito-serverless-operator/issues
about: GitHub Issues page in case you need to report a bug or wish to ask for a new feature.
- name: Question
url: https://github.com/kiegroup/kogito-serverless-operator/discussions
url: https://github.com/apache/incubator-kie-kogito-serverless-operator/discussions
about: I have a question about how to use the operator.
4 changes: 2 additions & 2 deletions .github/workflows/jenkins-tests-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
- name: DSL tests
uses: kiegroup/kie-ci/.ci/actions/dsl-tests@main
with:
main-config-file-repo: kiegroup/kogito-pipelines
main-config-file-repo: apache/incubator-kie-kogito-pipelines
main-config-file-path: .ci/jenkins/config/main.yaml
branch-config-file-repo: kiegroup/kogito-pipelines
branch-config-file-repo: apache/incubator-kie-kogito-pipelines