jenkinsci / ghprb-plugin

github pull requests builder plugin for Jenkins
https://plugins.jenkins.io/ghprb/
MIT License
502 stars 608 forks source link

Individual commit statuses for each configuration in a matrix project #113

Open MSch opened 9 years ago

MSch commented 9 years ago

We're triggering a matrix project using GHPRB and we'd love individual commit statuses for every configuration in the matrix project. Doing just ci/ios/${ARCHITECTURE}/{$IOS_VERSION} didn't work :/

DavidTanner commented 9 years ago

103 will give more options for updating the status. I am going to make a couple changes real quick, then publish it.

MSch commented 9 years ago

@DavidTanner is this going to be affecting the "Commit Status Context" field? (The one used to distinguish between different "checkboxes" on GitHub)?

DavidTanner commented 9 years ago

@MSch I am going to have it resolve any environment variables, or defaults from the project.

MSch commented 9 years ago

@DavidTanner Awesome. Appreciate it!

DavidTanner commented 9 years ago

Landed in build 1.24

MSch commented 9 years ago

@DavidTanner Thanks for the quick turnaround, but I just tried it and unfortunately it doesn't fix the issue.

We have a matrix project that gets triggered by the GH PR, so this matrix project then sets the commit status context, but the individual configurations that are run by it do not set a context.

So with the latest version I can configure a commit status context of ci/ios/${MY_VARIABLE_FROM_THE_MATRIX_PROJECT}, but this does not resolve the variable, since it only sets the commit status context on the "top-level" matrix project, not on each configuration in the matrix project.

When I actually want is a separate commit status context for every configuration in the matrix project (and ideally I could skip the commit status context for the matrix project itself, since that's not interesting for people looking at the PR)

DavidTanner commented 9 years ago

I see what you mean. In that case you want the status updated by the build manager as each completes. Currently there are only three points that interact with GitHub, trigger job, job started, and job finished.

I haven't done any work in the BuildManager code, but if you know your way around java you are welcome to add to the code in a pull request.

MSch commented 9 years ago

@DavidTanner Thanks for the info. I haven't done any development on Jenkins ever, how much work do you think it is to add this?

DavidTanner commented 9 years ago

I am not sure. @mdelapenya was the one that added the support for build flows, he might be able to provide some info.

mdelapenya commented 9 years ago

HI everybody, just to clarify: @MSch, you want to have as many commit statuses as matrix configurations in the job, so you could eventually print all statuses in the comment. Something like this:

Android 2.x -> OK
Android 3.x -> FAILED
Android 4.x -> OK
Android 5.x -> OK

Where each Android version is a value on the axis

Is that correct?

MSch commented 9 years ago

@mdelapenya I think so :)

I want to have as many commit status contexts as matrix configurations in the job, so that Android 2.x, Android 3.x, etc show up separately in the GitHub PR, just as clahub, continuous-integration/travis and codeclimate do here:

so you could eventually print all statuses in the comment

Just to clarify: I want to print the statuses as "commit status context" (see image above), not in a comment on the PR or the description field of the commit status.

mdelapenya commented 9 years ago

I took a quick look onto the code, and there is a method to write a commit status in a context

repo.createCommitStatus(sha1, state, url, message, context);

I guess calling it on each matrix configuration value will work.

Would it be enough?

MSch commented 9 years ago

@mdelapenya if that resolves variables in the context string than that would be perfect, I would just set the context to android/${ANDROID_VERSION} in the project configuration and that'd be it.

mdelapenya commented 9 years ago

The AbstractBuild object has a getVariables method.

So if you iterate through the matrix builds, then you'll have the variables on each one.

Take into account that you should move the createCommitStatus call in the onBuildComplete(...) method to the build manager, so that there could be more that one commit status, each on the context provided by the build

MSch commented 9 years ago

:+1: thanks!

mdelapenya commented 9 years ago

Just mention me in the pull if you want it or if you need help ;)

brianjmurrell commented 7 years ago

Any progress here? We too would like the individual child jobs (the intersections of the axes) to post their own status to GitHub.

Actually, it looks like it might be somewhat working. With the config set to:

    <org.jenkinsci.plugins.ghprb.upstream.GhprbUpstreamStatus plugin="ghprb@1.36.2">
      <showMatrixStatus>false</showMatrixStatus>
      <commitStatusContext>ci/jenkins/ssi/${arch}</commitStatusContext>
      <triggeredStatus></triggeredStatus>
      <startedStatus></startedStatus>
      <statusUrl></statusUrl>
      <addTestResults>false</addTestResults>
    </org.jenkinsci.plugins.ghprb.upstream.GhprbUpstreamStatus>

I get status for:

ci/jenkins/ssi/${arch}

and

ci/jenkins/ssi/x86_64

With the former showing a Details link to the parent job and the latter showing a Details link to the child job. So, really, just need the variable substitution in the parent to substitute an empty value (and suppress the final /) for an empty variable instead of the variable name.

bjoernhaeuser commented 6 years ago

I am closing this for now. If there is still momentum in need, lets reopen and get it ouf of the door.

brianjmurrell commented 6 years ago

@bjoernhaeuser I'm not sure I understand why you are closing this. This is still a very real issue for us. We have commit status' being overwritten because of this lack of being able to add which axis in the matrix it is updating for.

bjoernhaeuser commented 6 years ago

All good! Just trying to cleanup some old issues.

Are you interested in trying to provide the PR like discussed in this issue?

brianjmurrell commented 6 years ago

I wish I could. Java and hacking it in the Jenkins environment are not something I have had time to get into yet though.