#46 Avoid issue with SCM connection
Merged 4 years ago by mikeb. Opened 4 years ago by mkovarik.
mkovarik/c3i-library clone_retries_sleep  into  master

file modified
+2
@@ -26,6 +26,8 @@ 

  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

@@ -75,10 +75,8 @@ 

            }

  

            // 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}"

  

file modified
+7
@@ -192,7 +192,14 @@ 

      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: [

Connection to pagure.io is sometimes failing with domain resolution
issue. Adding sleep between SCM checkout retries .

Pull-Request has been merged by mikeb

4 years ago