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

Git plugin env GIT_PREVIOUS_SUCCESSFUL_COMMIT is incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • git-plugin, pipeline
    • None
    • Jenkins 2.73.1,
      Pipeline Model Definition Plugin 1.2,
      bitbucket branch source plugin 2.2.2

      Git plugin is returning incorrect commits when PRs are merged between branch and target.
      first build of PR-699 first build passes since it gets HEAD^^^^^
      Second build tries to use env but gets incorrect commit sha and git throws 
      invalid range

      Console output

      Getting changes from git using 073bba565596a087085c574aa73403ae0cd58299
      fatal: Invalid revision range 073bba565596a087085c574aa73403ae0cd58299..head
      

      The PR has 4 git build data with different commits  Due to different checkouts, I assume, where PRs are being merged with target.

      Solution is to only use git log on a non PR.... But we upload to hockeyapp on PR and development with gradle.

      pipeline {
        agent none
        stages {
          stage('Build') {
            agent { label 'android' }
            steps {
              sh './gradlew build'
            }
          }
          stage('Deploy to HockeyApp') {
            agent { label 'android' }
            steps {
              sh './gradlew clean HockeyAppBeyondRelease'
            }
          }
          stage('UI Tests') {
            agent none
            when { anyOf { branch 'development'; branch 'RunUITests' } }
            steps {
              script {
                throttle(['android-emulator']) {
                  node('android') {
                    checkoutWithEnv {
                      try {
                        sh 'bundle install'
                        sh 'bundle exec fastlane uitest'
                      } catch(ex) {
                        throw ex
                      }
                    }
                  }
                }
              }
            }
          }
          stage('Deploy Google Play') {
            agent { label 'android' }
            when { branch 'master' }
            steps {
              sh './gradlew clean publishApkBeyondRelease'
            }
          }
        }
      }

      Gradle code trying to get nice log:

       

      def since = System.getenv('GIT_PREVIOUS_SUCCESSFUL_COMMIT') ?: "HEAD^^^^^"
      git log "${since}..head"

       

            Unassigned Unassigned
            casz Joseph Petersen (old)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: