mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-14 01:49:56 +08:00
optimize checkouts
Only checkout exactly the code we need to run the tests. This should help work around errors and timeouts (early EOF/index-pack failed) from Pagure. Jenkins seems to require a minimum of depth=2 or it fails when walking the revision history. Using a shallow clone is safe for PRs because we're always building from the head of the PR branch (OpenShift doesn't have a way to specify a non-head commit on a PR branch). When building from the master branch we use depth=10 to avoid a race condition in case multiple commits have been pushed in quick succession. The integration test job is launched using the exact revision of the code that was used to build the images, to ensure the results are valid.
This commit is contained in:
@@ -56,9 +56,20 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
// check out specified branch/commit
|
||||
def srcRef = env.MBS_GIT_REF.startsWith('pull/') ? env.MBS_GIT_REF : "heads/${env.MBS_GIT_REF}"
|
||||
checkout([$class: 'GitSCM',
|
||||
branches: [[name: params.MBS_GIT_REF]],
|
||||
userRemoteConfigs: [[url: params.MBS_GIT_REPO, refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pull/*/head']],
|
||||
userRemoteConfigs: [
|
||||
[
|
||||
name: 'origin',
|
||||
url: params.MBS_GIT_REPO,
|
||||
refspec: "+refs/${srcRef}:refs/remotes/origin/${env.MBS_GIT_REF}",
|
||||
],
|
||||
],
|
||||
extensions: [
|
||||
[$class: 'CleanBeforeCheckout'],
|
||||
[$class: 'CloneOption', noTags: true, shallow: true, depth: 2, honorRefspec: true],
|
||||
],
|
||||
])
|
||||
|
||||
// get current commit ID
|
||||
|
||||
@@ -55,10 +55,23 @@ pipeline {
|
||||
// Don't set ENVIRONMENT_LABEL in the environment block! Otherwise you will get 2 different UUIDs.
|
||||
env.ENVIRONMENT_LABEL = "test-${env.TEST_ID}"
|
||||
|
||||
def srcRef = params.MBS_GIT_REF.startsWith('pull/') ? params.MBS_GIT_REF : 'heads/master'
|
||||
def localRef = params.MBS_GIT_REF.startsWith('pull/') ? params.MBS_GIT_REF : 'master'
|
||||
def cloneDepth = params.MBS_GIT_REF.startsWith('pull/') ? 2 : 10
|
||||
// check out specified branch/commit
|
||||
checkout([$class: 'GitSCM',
|
||||
branches: [[name: params.MBS_GIT_REF]],
|
||||
userRemoteConfigs: [[url: params.MBS_GIT_REPO, refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pull/*/head']],
|
||||
userRemoteConfigs: [
|
||||
[
|
||||
name: 'origin',
|
||||
url: params.MBS_GIT_REPO,
|
||||
refspec: "+refs/${srcRef}:refs/remotes/origin/${localRef}",
|
||||
],
|
||||
],
|
||||
extensions: [
|
||||
[$class: 'CleanBeforeCheckout'],
|
||||
[$class: 'CloneOption', noTags: true, shallow: true, depth: cloneDepth, honorRefspec: true],
|
||||
],
|
||||
])
|
||||
|
||||
// get current commit ID
|
||||
|
||||
@@ -150,16 +150,20 @@ objects:
|
||||
script {
|
||||
// checking out the polled branch
|
||||
def polledBranch = env.PAGURE_POLLING_FOR_PR == 'true' ? 'origin/pull/*/head' : "origin/${PAGURE_POLLED_BRANCH}"
|
||||
def srcRef = env.PAGURE_POLLING_FOR_PR == 'true' ? 'pull/*/head' : "heads/${PAGURE_POLLED_BRANCH}"
|
||||
def scmVars = checkout([$class: 'GitSCM',
|
||||
branches: [[name: polledBranch]],
|
||||
userRemoteConfigs: [
|
||||
[
|
||||
name: 'origin',
|
||||
url: env.GIT_URL,
|
||||
refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pull/*/head',
|
||||
refspec: "+refs/${srcRef}:refs/remotes/${polledBranch}",
|
||||
],
|
||||
],
|
||||
extensions: [[$class: 'CleanBeforeCheckout']],
|
||||
extensions: [
|
||||
[$class: 'CleanBeforeCheckout'],
|
||||
[$class: 'CloneOption', noTags: true, shallow: true, depth: 2, honorRefspec: true],
|
||||
],
|
||||
])
|
||||
env.MBS_GIT_COMMIT = scmVars.GIT_COMMIT
|
||||
// setting build display name
|
||||
@@ -206,10 +210,13 @@ objects:
|
||||
[
|
||||
name: 'origin',
|
||||
url: env.GIT_URL,
|
||||
refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pull/*/head',
|
||||
refspec: "+refs/heads/${env.MBS_GIT_BRANCH}:refs/remotes/origin/${env.MBS_GIT_BRANCH}",
|
||||
],
|
||||
],
|
||||
extensions: [[$class: 'CleanBeforeCheckout']],
|
||||
extensions: [
|
||||
[$class: 'CleanBeforeCheckout'],
|
||||
[$class: 'CloneOption', noTags: true, shallow: true, depth: 2, honorRefspec: true],
|
||||
],
|
||||
])
|
||||
script {
|
||||
dir('openshift/integration/koji/pipelines') {
|
||||
|
||||
Reference in New Issue
Block a user