Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-60304

Branches and merge requests disappear when calls to GitLab fail

XMLWordPrintable

      How was this detected?

      Branches in multibranch pipelines for projects hosted in GitLab.com started randomly appearing and disappearing (i.e. random results after every scan).

      What's causing it?

      We have discovered this issue by accident due to a bug in GitLab (https://gitlab.com/gitlab-org/gitlab/issues/37059) which causes the calls to /api/v*/projects/*/branches to return status code 500.

      The gitlab-branch-source-plugin unfortunately handles the exceptions which are thrown during the scan incorrectly. The exceptions are ignored and only the stacktrace is printed into the output.

      Line in code: https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/master/src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMSource.java#L537

      Because of this, Jenkins is not aware that the scan has failed and treats the empty list of branches and merge requests as successful result and thinks all the branches and MRs have been deleted from the repository.

      How to fix this?

      • Throw the exception out of the method as one of the exception types which are declared by the inherited method contract (e.g. IOException)
      • Given how reliable GitLab APIs are (based on our experience over the last ~6 months as a paying customer...), retry logic should mitigate most of these issues.

       

            baymac Parichay Barpanda
            lholota Lukas Holota
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: