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

Multibranch pipeline - existing branch seen as first time build

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • None
    • git-plugin:4.0.0 git-client-plugin:3.0.0. Jenkins:2.204. AWS Linux AMI 2.

      Sometimes when building an existing multi-branch pipeline, the build is incorrectly regarded as first-time. The console log shows "First time build. Skipping changelog." ,and the build-overview says "no changes", both incorrectly.

       

      This results in confusion whether commits/merges have been done correctly as they are not visible.

          [JENKINS-60159] Multibranch pipeline - existing branch seen as first time build

          Mark Waite added a comment - - edited

          Can you provide more details about conditions that might cause a build to be identified as a first-time build?

          Were there specific changes that happened at the time in the git repository, in the job definition, or in the agent definitions?

          Are you using ephemeral or static agents?

          I inserted detection checks into several of my test jobs in hopes of seeing it, but did not see it. Will need more details in order to duplicate the problem.

          Any other hints that might make the problem repeatable?

          Mark Waite added a comment - - edited Can you provide more details about conditions that might cause a build to be identified as a first-time build? Were there specific changes that happened at the time in the git repository, in the job definition, or in the agent definitions? Are you using ephemeral or static agents? I inserted detection checks into several of my test jobs in hopes of seeing it, but did not see it. Will need more details in order to duplicate the problem. Any other hints that might make the problem repeatable?

          Thomas Minke added a comment -

          Hi markewaite, thanks for your quick response. I'm looking for more info to reproduce this issue, but I'm afraid I've got very little.

          • Today, 4 out of 5 builds show as 'first-time' in the console logs, and 1 shows a changelog.
          • These builds were both after branch merges and direct commits. Nothing irregular in the Git repository as far as I can see.
          • The Jenkinsfile was not changed in all of the builds.
          • We use a static agent with one SSH slave. All 5 builds that I started today ran on this SSH slave.  

          Do you have any hints which information would be relevant for reproducing or debugging? 

          Thomas Minke added a comment - Hi markewaite , thanks for your quick response. I'm looking for more info to reproduce this issue, but I'm afraid I've got very little. Today, 4 out of 5 builds show as 'first-time' in the console logs, and 1 shows a changelog. These builds were both after branch merges and direct commits. Nothing irregular in the Git repository as far as I can see. The Jenkinsfile was not changed in all of the builds. We use a static agent with one SSH slave. All 5 builds that I started today ran on this SSH slave.   Do you have any hints which information would be relevant for reproducing or debugging? 

          Thomas Minke added a comment -

          markewaite, one other thing: we have another issue at the moment regarding Git checkout. Sometimes the checkout fails with an error message, without failing the build. This results in a deployment of the code without updating. I will create a separate issue for this, but it might be related.

          Thomas Minke added a comment - markewaite , one other thing: we have another issue at the moment regarding Git checkout. Sometimes the checkout fails with an error message, without failing the build. This results in a deployment of the code without updating. I will create a separate issue for this, but it might be related.

          Mark Waite added a comment -

          I'm not aware of cases where a checkout fails and does not fail the build. Definitely provide examples of the problem in a separate issue.

          Mark Waite added a comment - I'm not aware of cases where a checkout fails and does not fail the build. Definitely provide examples of the problem in a separate issue.

          I wanted to report I am experiencing this issue as well, which results in some plugins for Jira not working.

          Michael Kroell added a comment - I wanted to report I am experiencing this issue as well, which results in some plugins for Jira not working.

          I'm using the 'Bitbucket Branch Source' plugin and see this on all builds, all branches and can't find any way to make it record changes. I fiddled with pretty much any git setting/extension I could find, it just keeps telling me "First time build. Skipping changelog."

          It seems to have something to do with not being able to determine the revision of the previous build. What does work is overriding the checkout and getting changes against a specific branch:
          {{
          options

          { skipDefaultCheckout(true) }

          stages {
          stage('Setup') {
          steps {

          checkout(changelog: true, scm:[
          $class: 'GitSCM',
          branches: scm.branches,
          doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
          extensions: [[$class: 'ChangelogToBranch', options: [compareRemote: 'origin', compareTarget: 'master']],[$class: 'AuthorInChangelog'], [$class: 'CloneOption', noTags: false, reference: '', shallow: false], [$class: 'CleanBeforeCheckout']],
          userRemoteConfigs: scm.userRemoteConfigs
          ])
          }}
          Based of https://devops.stackexchange.com/questions/4379/jenkins-shows-no-changes-in-any-of-the-builds
          However that shows way to many changes.

          Another observation is that on some projects I use a shared library, changes made to the library do show up. So something works...

          Arjan Veenstra added a comment - I'm using the 'Bitbucket Branch Source' plugin and see this on all builds, all branches and can't find any way to make it record changes. I fiddled with pretty much any git setting/extension I could find, it just keeps telling me "First time build. Skipping changelog." It seems to have something to do with not being able to determine the revision of the previous build. What does work is overriding the checkout and getting changes against a specific branch: {{ options { skipDefaultCheckout(true) } stages { stage('Setup') { steps { checkout(changelog: true, scm:[ $class: 'GitSCM', branches: scm.branches, doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, extensions: [[$class: 'ChangelogToBranch', options: [compareRemote: 'origin', compareTarget: 'master'] ], [$class: 'AuthorInChangelog'] , [$class: 'CloneOption', noTags: false, reference: '', shallow: false] , [$class: 'CleanBeforeCheckout'] ], userRemoteConfigs: scm.userRemoteConfigs ]) }} Based of https://devops.stackexchange.com/questions/4379/jenkins-shows-no-changes-in-any-of-the-builds However that shows way to many changes. Another observation is that on some projects I use a shared library, changes made to the library do show up. So something works...

          Eric added a comment -

          I am encountering the exact same issue as Arjan.  I'm also using the Bitbucket Branch Source plugin and a shared library.  I'm experiencing this issue on a new instance I'm trying to build to replace our existing one.  The existing jenkins does not experience this issue.  The job configuration between the 2 instances is pretty much identical yet the new kubernetes instance always sees every build as a new build.  Library changes were showing up but I disabled that so that part worked for me as well.

          Eric added a comment - I am encountering the exact same issue as Arjan.  I'm also using the Bitbucket Branch Source plugin and a shared library.  I'm experiencing this issue on a new instance I'm trying to build to replace our existing one.  The existing jenkins does not experience this issue.  The job configuration between the 2 instances is pretty much identical yet the new kubernetes instance always sees every build as a new build.  Library changes were showing up but I disabled that so that part worked for me as well.

          Eric added a comment -

          I solved my issue it seems.  I tried a few different things.  The thing that seemed to fix it was removing the refspec configuration and just using the default.  I copied that setting from the old jenkins instance and for some reason I guess it broke things on the new instance.

          Eric added a comment - I solved my issue it seems.  I tried a few different things.  The thing that seemed to fix it was removing the refspec configuration and just using the default.  I copied that setting from the old jenkins instance and for some reason I guess it broke things on the new instance.

          I think I found a way to make it work properly. Firstly I need checkout via SSH, secondly I need to set the refspec to the default:

          If either one of those is not done I will always see "First time build. Skipping changelog.", but with both those settings it seems to work as expected.

          Arjan Veenstra added a comment - I think I found a way to make it work properly. Firstly I need checkout via SSH, secondly I need to set the refspec to the default: If either one of those is not done I will always see "First time build. Skipping changelog.", but with both those settings it seems to work as expected.

          Paul Anand added a comment - - edited

          I am also facing this issue.

           

          What was the activity?

          1. Created an Organization Folder in Jenkins.
          2. Added a Repository Source, selecting Bitbucket Team/Project.

          What was observed?

          1. When building a job for the first time, the following logs are printed in the console:
            First time build. Skipping changelog.
          2. Subsequent builds do not contain the changelog. The above log statement is observed.

          Workaround

          1. Added the option to Checkout over SSH.
          2. When building a job for the first time, the following logs are printed in the console:
            First time build. Skipping changelog.
          3. Subsequent builds contain the changelog.

           

          It looks like the changelog does not work when checking out using OAuth credentials.

          Paul Anand added a comment - - edited I am also facing this issue.   What was the activity? Created an Organization Folder in Jenkins. Added a Repository Source , selecting  Bitbucket Team/Project . Configured the Credentials using OAuth (as documented in https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/docs/USER_GUIDE.adoc#oauth-credentials) Left everything else as default. What was observed? When building a job for the first time, the following logs are printed in the console: First time build. Skipping changelog. Subsequent builds do not contain the changelog. The above log statement is observed. Workaround Added the option to Checkout over SSH . When building a job for the first time, the following logs are printed in the console: First time build. Skipping changelog. Subsequent builds contain the changelog .   It looks like the changelog does not work when checking out using OAuth credentials.

            Unassigned Unassigned
            thomasminke Thomas Minke
            Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: