Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-07-02 Thread Liam Newman
Yes, you should absolutely create a JIRA. On Tuesday, July 2, 2019 at 8:46:42 AM UTC-7, Julien HENRY wrote: > > Hi Jesse, > > Here are 3 PRs to implement the proposed change. I did only Bitbucket so > far, but if you confirm I'm on the good track, I will submit the same for > GitHub (I have

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-07-02 Thread Julien HENRY
Hi Jesse, Here are 3 PRs to implement the proposed change. I did only Bitbucket so far, but if you confirm I'm on the good track, I will submit the same for GitHub (I have the changes locally, just haven't tested end-to-end). https://github.com/jenkinsci/scm-api-plugin/pull/71

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-13 Thread Jesse Glick
On Thu, Jun 13, 2019 at 8:53 AM Julien HENRY wrote: > the GIT_COMMIT variable […] was not defined out of the box in my tests. I had > to get it from the return of the checkout step Yes, each `checkout` step in the build, of which there could be zero or more, can return its own metadata. For a

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-13 Thread Julien HENRY
Hi Ivan, Thanks for the notice. Your solution is heavily relying on the presence of the GIT_COMMIT variable, which was not defined out of the box in my tests. I had to get it from the return of the checkout step, which is not a good solution for us, since we want our step to work without asking

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-13 Thread Ivan Fernandez Calvo
we faced the same problem a few months ago, we've resolved it by adding a calculated environment variable for more details see https://groups.google.com/forum/#!topic/jenkinsci-dev/Dus0VX6y04g -- You received this message because you are subscribed to the Google Groups "Jenkins Developers"

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-12 Thread Jesse Glick
On Wed, Jun 12, 2019 at 3:56 AM Julien HENRY wrote: > Would you be ok to accept a contribution from SonarSource where we would add > a new env variable (like CHANGE_COMMIT) to expose the PR head commit sha to > the pipeline? We are interested to support both GitHub and Bitbucket, so we > would

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-12 Thread Julien HENRY
Hi Jesse, Our users are strongly asking for a better support of PR status update by SonarQube/SonarCloud when build is triggered by Jenkins. We don't like the try-fail strategy (trying to annotate current commit, then fallback on parent). Would you be ok to accept a contribution from

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Jesse Glick
On Wed, Jun 5, 2019 at 11:06 AM Julien HENRY wrote: > https://github.com/deis/workflow-cli/blob/a285f6914f10ce81d0afe5d53603aa36cda78ccd/Jenkinsfile#L67 That particular implementation is wrong anyway, since the PR head commit might happen to be a merge commit, for example by a developer

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Julien HENRY
FYI, the kind of trick I would like to avoid to maintain is what this project is doing: https://github.com/deis/workflow-cli/blob/a285f6914f10ce81d0afe5d53603aa36cda78ccd/Jenkinsfile#L67 Le mercredi 5 juin 2019 16:03:34 UTC+2, Jesse Glick a écrit : > > On Wed, Jun 5, 2019 at 8:21 AM Julien

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Jesse Glick
On Wed, Jun 5, 2019 at 8:21 AM Julien HENRY wrote: > Since the commit hash we are collecting currently in the pipeline is > something transient that doesn't exists on GitHub Note that as of JENKINS-43194 it _may_ be visible from GitHub APIs. I would not advise relying on that, though. >

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Jesse Glick
On Wed, Jun 5, 2019 at 6:37 AM Joseph P wrote: > branch source plugin uses branch API plugin which contributes the environment > variables. > There is also a way for plugins to retrieve this see >

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Julien HENRY
Hi Jesse, Publishing of PR status happens on SonarQube server side, asynchronously. Since the commit hash we are collecting currently in the pipeline is something transient that doesn't exists on GitHub, it is impossible to find the parent. We would have to collect the parent in advance

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Joseph P
If SCMHead is not the thing you want: You can retrieve from the git build data: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L1328 On Wednesday, June 5, 2019 at 12:39:19 PM UTC+2, Joseph P wrote: > > To clarify from the SCMHead: you should be

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Joseph P
To clarify from the SCMHead: you should be able to get the commit sha On Wednesday, June 5, 2019 at 12:37:37 PM UTC+2, Joseph P wrote: > > Jesse that is simply not true for branch source plugins: > > branch source plugin uses branch API plugin which contributes the > environment variables. >

Re: Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-05 Thread Joseph P
Jesse that is simply not true for branch source plugins: branch source plugin uses branch API plugin which contributes the environment variables. There is also a way for plugins to retrieve this see

Accessing PR head commit sha from a pipeline using branch source plugin

2019-06-04 Thread Julien HENRY
Hi, We are trying to simplify integration of SonarQube with most popular pull request provider, like GitHub or Bitbucket. Those ALM usually provide some API to report issues on PR (GitHub checks, Bitbucket Code Insight, ...). The APIs require to pass the PR HEAD commit sha1. We are trying to get