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

GIT_URL env variable not set for multibranch PR build

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins LTS 2.263.4 on RHEL7 with Red Hat OpenJDK 8
      git-plugin 4.6.0
      git-client-plugin 3.6.0
      bitbucket-branch-source-plugin 2.9.7
    • git plugin 4.7.1 released 4 Apr 2021

      In a multibranch pipeline job we see that GIT_URL is set in builds for branches, but for PR builds it is null. However, GIT_COMMIT is set in both cases.
      We're using bitbucket-branch-source-plugin for the multibranch part but I believe it's git-plugin that sets the GIT_URL env variable.
      We are also using declarative pipelines, with implicit checkout.

      It should be reproducable with a simple pipeline like this:

      pipeline {
          agent any
          stages {
              stage('Test') {
                  steps {
                      echo "GIT_COMMIT: ${env.GIT_COMMIT}"
                      echo "GIT_URL: ${env.GIT_URL}"
                  }
              }
          }
      }
      

            Unassigned Unassigned
            ahammar Anders Hammar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: