From 1de6b0bba2f258de6d45992ffb3a54bba9b1e66d Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 3 Aug 2020 15:38:59 +0200 Subject: [PATCH] ci: pass Kubernetes version as parameter to mini-e2e job Move the mini-e2e job into a template-job and generate two jobs out of it: mini-e2e/k8s-1.17.8 and mini-e2e/k8s-1.18.5 By passing the k8s_version as variable to the job-template, and placing it in the parameters for the mini-e2e.groovy script, all hard-coded occurences of the Kubernetes version can be replaced by the {k8s_version} placeholder. See-also: https://jenkins-job-builder.readthedocs.io/en/latest/definition.html#job-template Signed-off-by: Niels de Vos --- jobs/mini-e2e.yaml | 23 ++++++++++++++++++++--- mini-e2e.groovy | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/jobs/mini-e2e.yaml b/jobs/mini-e2e.yaml index 1179df5e7..98f1f6fb9 100644 --- a/jobs/mini-e2e.yaml +++ b/jobs/mini-e2e.yaml @@ -1,6 +1,14 @@ --- -- job: +- project: name: mini-e2e + k8s_version: + - '1.17.8' + - '1.18.5' + jobs: + - 'mini-e2e/k8s-{k8s_version}' + +- job-template: + name: 'mini-e2e/k8s-{k8s_version}' project-type: pipeline sandbox: true concurrent: true @@ -10,6 +18,14 @@ - build-discarder: days-to-keep: 7 artifact-days-to-keep: 7 + # default variables + k8s_version: '' + # generated parameters for the job (used in the groovy script) + parameters: + - string: + name: k8s_version + default: '{k8s_version}' + description: Kubernetes version to deploy in the test cluster. pipeline-scm: scm: - git: @@ -21,8 +37,9 @@ lightweight-checkout: true triggers: - github-pull-request: - status-context: ci/centos/mini-e2e/k8s-1.18 - trigger-phrase: '/(re)?test ((all)|(ci/centos/mini-e2e(/k8s-1.18)?))' + status-context: 'ci/centos/mini-e2e/k8s-{k8s_version}' + # yamllint disable-line rule:line-length + trigger-phrase: '/(re)?test ((all)|(ci/centos/mini-e2e(/k8s-{k8s_version})?))' permit-all: true # TODO: set github-hooks to true when it is configured in GitHub github-hooks: false diff --git a/mini-e2e.groovy b/mini-e2e.groovy index 86619a284..1f22a61f7 100644 --- a/mini-e2e.groovy +++ b/mini-e2e.groovy @@ -46,9 +46,9 @@ node('cico-workspace') { // build e2e.test executable ssh 'cd /opt/build/go/src/github.com/ceph/ceph-csi && make containerized-build CONTAINER_CMD=podman TARGET=e2e.test' } - stage('deploy k8s v1.18.3 and rook') { + stage('deploy k8s v{k8s_version} and rook') { timeout(time: 30, unit: 'MINUTES') { - ssh './single-node-k8s.sh --k8s-version=v1.18.3' + ssh './single-node-k8s.sh --k8s-version=v${k8s_version}' } } stage('run e2e') {