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

Building branch on multibranch job without scanning will build stale commit

    • 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.

          [JENKINS-73267] Building branch on multibranch job without scanning will build stale commit

          Pinned comments

          This was discovered while addressing JENKINS-72120. The tag portion of this issue will be resolved as part of that ticket- the fix for this one will likely just be for branches and pull request refs (though hopefully both are resolved, and promptly)

          Martin Henschke added a comment - This was discovered while addressing JENKINS-72120 . The tag portion of this issue will be resolved as part of that ticket- the fix for this one will likely just be for branches and pull request refs (though hopefully both are resolved, and promptly)

          All comments

          This was discovered while addressing JENKINS-72120. The tag portion of this issue will be resolved as part of that ticket- the fix for this one will likely just be for branches and pull request refs (though hopefully both are resolved, and promptly)

          Martin Henschke added a comment - This was discovered while addressing JENKINS-72120 . The tag portion of this issue will be resolved as part of that ticket- the fix for this one will likely just be for branches and pull request refs (though hopefully both are resolved, and promptly)

          Brady Shober added a comment -

          Should the fix for this issue have resolved a 

          ERROR: Could not determine exact tip revision of master; falling back to nondeterministic checkout

          message that we see at the beginning of our builds? We see this message when we have not done a scan recently but try to initiate a build. The build ultimately fails later on with a 

          ERROR: Could not determine exact tip revision of master

          Brady Shober added a comment - Should the fix for this issue have resolved a  ERROR: Could not determine exact tip revision of master; falling back to nondeterministic checkout message that we see at the beginning of our builds? We see this message when we have not done a scan recently but try to initiate a build. The build ultimately fails later on with a  ERROR: Could not determine exact tip revision of master

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

              Created:
              Updated:
              Resolved: