From 159d23e6859976f504443aaa852e314d486d8653 Mon Sep 17 00:00:00 2001 From: Michal Kovarik Date: Mar 11 2020 08:39:13 +0000 Subject: Avoid issue with SCM connection Connection to pagure.io is sometimes failing with domain resolution issue. Adding sleep between SCM checkout retries . --- diff --git a/roles/c3i/README.md b/roles/c3i/README.md index 351a11b..2f213e0 100644 --- a/roles/c3i/README.md +++ b/roles/c3i/README.md @@ -26,6 +26,8 @@ oc create secret generic pagure-api-key --from-literal=secrettext=${KEY} oc label secret pagure-api-key credential.sync.jenkins.openshift.io=true ``` +Due to pagure.io connection issue it's recommended to set 'SCM checkout retry count' in Jenkins global configuration to 10. + Workflows --------- ### Pre-merge diff --git a/roles/c3i/templates/build.Jenkinsfile b/roles/c3i/templates/build.Jenkinsfile index 5581b97..e3bfa1b 100644 --- a/roles/c3i/templates/build.Jenkinsfile +++ b/roles/c3i/templates/build.Jenkinsfile @@ -75,10 +75,8 @@ pipeline { } // FIXME: Due to a bug described in https://issues.jenkins-ci.org/browse/JENKINS-45489 - checkout([$class: 'GitSCM', - branches: [[name: env.GIT_REPO_REF]], - userRemoteConfigs: [[url: params.GIT_REPO, refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pull/*/head']], - ]) + c3i.clone(repo: params.GIT_REPO, + branch: env.GIT_REPO_REF) env.GIT_COMMIT = sh(returnStdout: true, script: 'git rev-parse HEAD').trim() echo "Build ${env.GIT_REPO_REF}, commit=${env.GIT_COMMIT}" diff --git a/vars/c3i.groovy b/vars/c3i.groovy index 857c41d..51130f7 100644 --- a/vars/c3i.groovy +++ b/vars/c3i.groovy @@ -192,7 +192,14 @@ def clone(Map args) { def depth = args.depth ?: branch == 'master' ? 10 : 2 opts.depth = depth } + def firstRun = true retry(args.retries ?: 5) { + if (firstRun) { + firstRun = false + } + else { + sleep time: 10, unit: 'SECONDS' + } return checkout([$class: 'GitSCM', branches: [[name: args.rev ?: branch]], userRemoteConfigs: [