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

Expose some Pull Request/Branch attributes as Environment Variables

      It would be very nice if we could use expose some variables just like github is doing.

      Environment Variables such as:

      bbprbActualCommit
      bbprbActualCommitAuthor
      bbprbActualCommitAuthorEmail
      bbprbPullDescription
      bbprbPullId
      bbprbPullLink
      bbprbPullTitle
      bbprbSourceBranch
      bbprbTargetBranch
      sha1

          [JENKINS-36421] Expose some Pull Request/Branch attributes as Environment Variables

          github-branch-source-plugin is not providing such variables.

          Antonio Muñiz added a comment - github-branch-source-plugin is not providing such variables.

          hugo fonseca added a comment -

          I'm sorry you mean that github-branch-source-plugin wont provide such variables (and being so we can close this) or that it is just currently not providing them?

          hugo fonseca added a comment - I'm sorry you mean that github-branch-source-plugin wont provide such variables (and being so we can close this) or that it is just currently not providing them?

          It is currently not providing them, and I think it will not.

          BTW I'd say it's not technically possible (without big hacks).

          Antonio Muñiz added a comment - It is currently not providing them, and I think it will not. BTW I'd say it's not technically possible (without big hacks).

          hugo fonseca added a comment -

          I understand. Just to make my point clear before we close this, let me explain what I would like to have:

          I want to publish notifications (email for example) when a build fails. On that email I want to add information about which pull request the build refers too and its author (I'm only working with pull requests)

          AFAIK Jenkins is receiving a webhook containing all that information https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-PullRequestEvents

          Technically it should be possible to get that information from my pipeline script (without having to hack). Yet, I'm not fully aware of how the pipeline script work internally neither how this plugin is built and I still haven't look into it, but in theory I'm not asking anything weird. But please, enlighten me and feel free to close this.

          hugo fonseca added a comment - I understand. Just to make my point clear before we close this, let me explain what I would like to have: I want to publish notifications (email for example) when a build fails. On that email I want to add information about which pull request the build refers too and its author (I'm only working with pull requests) AFAIK Jenkins is receiving a webhook containing all that information https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-PullRequestEvents Technically it should be possible to get that information from my pipeline script (without having to hack). Yet, I'm not fully aware of how the pipeline script work internally neither how this plugin is built and I still haven't look into it, but in theory I'm not asking anything weird. But please, enlighten me and feel free to close this.

          Nikolas Falco added a comment -

          These values are already available

          • bbprbActualCommit as GIT_COMMIT
          • bbprbActualCommitAuthor as GIT_AUTHOR_NAME
          • bbprbActualCommitAuthorEmail as GIT_AUTHOR_EMAIL
          • bbprbPullId -> CHANGE_ID
          • bbprbPullLink -> CHANGE_URL
          • bbprbSourceBranch -> CHANGE_BRANCH
          • bbprbTargetBranch -> CHANGE_TARGET
          • sha1 -> same as GIT_COMMIT

          The following values are not yet provided

          • bbprbPullDescription -> can be very long with HTML in it, I wont provide. If needed use CURL to the REST APIs
          • bbprbPullTitle -> if needed use CURL to the REST APIs

          Nikolas Falco added a comment - These values are already available bbprbActualCommit as GIT_COMMIT bbprbActualCommitAuthor as GIT_AUTHOR_NAME bbprbActualCommitAuthorEmail as GIT_AUTHOR_EMAIL bbprbPullId -> CHANGE_ID bbprbPullLink -> CHANGE_URL bbprbSourceBranch -> CHANGE_BRANCH bbprbTargetBranch -> CHANGE_TARGET sha1 -> same as GIT_COMMIT The following values are not yet provided bbprbPullDescription -> can be very long with HTML in it, I wont provide. If needed use CURL to the REST APIs bbprbPullTitle -> if needed use CURL to the REST APIs

            nfalco Nikolas Falco
            fonsecas72 hugo fonseca
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: