I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

      The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

      *Job config*
      ````
      build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
      Branches to build -1 : origin/master
      Branches to build - 2: origin/develop
      Branches to build - 3: ${sha1}
      Refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*

      • [√ ] Build when a change is pushed to GitHub
      • [√ ] GitHub Pull Request Builder
        ````

      *Jenkins and plugin versions*
      ````
      jenkins version: 2.7.1

      Git client plugin: 2.0.0
      Git plugin: 3.0.0
      GitHub API Plugin: 1.77
      GitHub plugin: 1.21.1
      GitHub Pull Request Builder: 1.33.1
      ````

          [JENKINS-38406] GIT_BRANCH wrongly set.

          Puneeth Nanjundaswamy created issue -
          Puneeth Nanjundaswamy made changes -
          Description Original: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>)
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          New: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          Puneeth Nanjundaswamy made changes -
          Description Original: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          New: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          Puneeth Nanjundaswamy made changes -
          Description Original: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          New: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: `+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*`

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          Puneeth Nanjundaswamy made changes -
          Description Original: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: `+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*`

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          New: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          Puneeth Nanjundaswamy made changes -
          Description Original: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          New: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: +refs/heads/\*:refs/remotes/origin/\* +refs/pull/\*:refs/remotes/origin/pr/\*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          Puneeth Nanjundaswamy made changes -
          Description Original: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: ${sha1}
          Refspec: +refs/heads/\*:refs/remotes/origin/\* +refs/pull/\*:refs/remotes/origin/pr/\*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          New: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: \$\{sha1\}
          Refspec: +refs/heads/\*:refs/remotes/origin/\* +refs/pull/\*:refs/remotes/origin/pr/\*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          Puneeth Nanjundaswamy made changes -
          Description Original: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: \$\{sha1\}
          Refspec: +refs/heads/\*:refs/remotes/origin/\* +refs/pull/\*:refs/remotes/origin/pr/\*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          New: I have a jenkins job that runs when code is pushed to `master` and `develop` branch. This job also picks up PRs. This job also has `sha1` as a build parameter to trigger builds manually.

          The job picks up PRs and builds them. Same with pushes to `master` or `develop`. The issue is when The job is triggered manually. It seems to pickup a random branch. sometimes a PR, sometimes `origin/develop`. The GIT_BRANCH environment variable is overwritten with some other branch and not sha1.

          **Job config**
          ````
          build parameters: sha1 (default value: origin/<branchName>) so technically, the job should fail as there is no branch called `origin/<branchName>`
          Branches to build -1 : origin/master
          Branches to build - 2: origin/develop
          Branches to build - 3: $\{sha1\}
          Refspec: +refs/heads/\*:refs/remotes/origin/\* +refs/pull/\*:refs/remotes/origin/pr/\*

          - [√ ] Build when a change is pushed to GitHub
          - [√ ] GitHub Pull Request Builder
          ````

          **Jenkins and plugin versions**
          ````
          jenkins version: 2.7.1

          Git client plugin: 2.0.0
          Git plugin: 3.0.0
          GitHub API Plugin: 1.77
          GitHub plugin: 1.21.1
          GitHub Pull Request Builder: 1.33.1
          ````
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]
          Stephen Connolly made changes -
          Link New: This issue is related to JENKINS-40389 [ JENKINS-40389 ]
          Stephen Connolly made changes -
          Labels New: scm-api-tidy-scrub

            Unassigned Unassigned
            puneeth_n Puneeth Nanjundaswamy
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: