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

Building branch on multibranch job without scanning will build stale commit

XMLWordPrintable

    • 4.1.0

      Steps to reproduce:

      • Create a multibranch pipeline pointing to a jenkins job, with discover branches but with no webhook configured
      • Scan the project, which should result in a build on commit aaaaaa
      • Push commit bbbbbb to the repository
      • Run the branch build

      Expected behaviour:

      The SCM will fetch and build revision bbbbbb

      Actual behaviour

      The SCM uses a cached revision from the last run, in this case aaaaaa and builds that

       

      This bug lies in the implementation of SCMSource#retrieve(SCMHead head, TaskListener listener). We currently persist the last seen revision as part of the SCM Head- this is fine when a webhook event arrives, forcing a fresh retrieval of the branch to get the latest head, but when we build without an event, it assumes there has been no push to the branch since the last scan occurred. This is not a safe assumption if building manually on branches, and never a safe assumption with tags (as these are not saving the revision at all).

      The fix for this issue is to reimplement retrieve to fetch the head from Bitbucket and serve that as the revision to the SCM instead of relying on the cached value.

            ssu2_atl Stanley
            mhenschke_atlassian Martin Henschke
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: