From 8f84e592d5262f3c1a4abd07a42df02fd40a2c71 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 7 Apr 2021 18:09:56 +0200 Subject: [PATCH] ci: do not re-checkout current branch When tests are started manually (through the Jenkins webui), there is no PR associated with the job. That means the `git_since` and `ref` are equal. Trying to create a new branch named `ref` will not work, as the branch was already created when cloning the repository with `git_since`. With this change, Jenkins jobs can be started manually. This makes it possible to run regular/nightly jobs as well. Signed-off-by: Niels de Vos --- ci-job-validation.groovy | 4 +++- containerized-tests.groovy | 4 +++- k8s-e2e-external-storage.groovy | 4 +++- mini-e2e-helm.groovy | 4 +++- mini-e2e.groovy | 4 +++- upgrade-tests.groovy | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ci-job-validation.groovy b/ci-job-validation.groovy index 8aefae4ca..41ad22af5 100644 --- a/ci-job-validation.groovy +++ b/ci-job-validation.groovy @@ -29,7 +29,9 @@ node('cico-workspace') { } sh "git clone --depth=1 --branch='${git_since}' '${git_repo}' ~/build/ceph-csi" - sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + if (ref != git_since) { + sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + } } stage('check doc-only change') { diff --git a/containerized-tests.groovy b/containerized-tests.groovy index 6d08f55dd..6ce1b3f71 100644 --- a/containerized-tests.groovy +++ b/containerized-tests.groovy @@ -47,7 +47,9 @@ node('cico-workspace') { } sh "git clone --depth=1 --branch='${git_since}' '${git_repo}' ~/build/ceph-csi" - sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + if (ref != git_since) { + sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + } } stage('check doc-only change') { diff --git a/k8s-e2e-external-storage.groovy b/k8s-e2e-external-storage.groovy index a057ed0e3..b5a3f80cd 100644 --- a/k8s-e2e-external-storage.groovy +++ b/k8s-e2e-external-storage.groovy @@ -57,7 +57,9 @@ node('cico-workspace') { } sh "git clone --depth=1 --branch='${git_since}' '${git_repo}' ~/build/ceph-csi" - sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + if (ref != git_since) { + sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + } } stage('check doc-only change') { diff --git a/mini-e2e-helm.groovy b/mini-e2e-helm.groovy index 11a839a96..400e08ccd 100644 --- a/mini-e2e-helm.groovy +++ b/mini-e2e-helm.groovy @@ -73,7 +73,9 @@ node('cico-workspace') { } sh "git clone --depth=1 --branch='${git_since}' '${git_repo}' ~/build/ceph-csi" - sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + if (ref != git_since) { + sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + } } stage('check doc-only change') { diff --git a/mini-e2e.groovy b/mini-e2e.groovy index 6edc38fb9..30cc39246 100644 --- a/mini-e2e.groovy +++ b/mini-e2e.groovy @@ -70,7 +70,9 @@ node('cico-workspace') { } sh "git clone --depth=1 --branch='${git_since}' '${git_repo}' ~/build/ceph-csi" - sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + if (ref != git_since) { + sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + } } stage('check doc-only change') { diff --git a/upgrade-tests.groovy b/upgrade-tests.groovy index 37465c8e7..cfdb30669 100644 --- a/upgrade-tests.groovy +++ b/upgrade-tests.groovy @@ -70,7 +70,9 @@ node('cico-workspace') { } sh "git clone --depth=1 --branch='${git_since}' '${git_repo}' ~/build/ceph-csi" - sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + if (ref != git_since) { + sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD" + } } stage('check doc-only change') {