Skip to content

Comments

[FIXED JENKINS-15045] Commit status API#23

Merged
ndeloof merged 3 commits intomasterfrom
commit-status-api
Jan 30, 2013
Merged

[FIXED JENKINS-15045] Commit status API#23
ndeloof merged 3 commits intomasterfrom
commit-status-api

Conversation

@ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Jan 17, 2013

Notifier to use GitHub status API

@buildhive
Copy link

Jenkins » github-plugin #26 SUCCESS
This pull request looks good
(what's this?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case: GitHub

case on "GitHub"
unused GitHubPushCause
@addisonj
Copy link

Really interested in this feature, any idea on what is still waiting and if I can be of help?

@pangratz
Copy link

👍 very useful addition!!

@adrien-aubel
Copy link

+1

ndeloof added a commit that referenced this pull request Jan 30, 2013
[FIXED JENKINS-15045] Commit status API
@ndeloof ndeloof merged commit ef22d01 into master Jan 30, 2013
@rdohms
Copy link

rdohms commented Feb 1, 2013

👍 when will this be available?

@kpfleming
Copy link
Contributor

I think this commit is incomplete; using the commit status API requires authentication to GitHub, which requires credentials. However, credentials can only be configured in the global config page if the user is allowing the GitHub plugin to automatically manage service hooks; if manual service hook management is enabled, there is no place to configure credentials (in other words, the same credentials are now serving another purpose).

I believe this can be fixed by moving the 'GitHub Credential' section of GitHubPushTrigger/global.jelly outside the radioblock section, but it might be even better to create a separate global config area for the credentials, since using them only for the commit status updates is unrelated to push triggering.

@ndeloof
Copy link
Contributor Author

ndeloof commented Feb 16, 2013

This should be delegated to the credentials-plugin anyway

2013/2/15 Kevin P. Fleming notifications@github.com

I think this commit is incomplete; using the commit status API requires
authentication to GitHub, which requires credentials. However, credentials
can only be configured in the global config page if the user is allowing
the GitHub plugin to automatically manage service hooks; if manual service
hook management is enabled, there is no place to configure credentials (in
other words, the same credentials are now serving another purpose).

I believe this can be fixed by moving the 'GitHub Credential' section of
GitHubPushTrigger/global.jelly outside the radioblock section, but it might
be even better to create a separate global config area for the credentials,
since using them only for the commit status updates is unrelated to
push triggering.


Reply to this email directly or view it on GitHubhttps://github.com//pull/23#issuecomment-13630654.

@kpfleming
Copy link
Contributor

Yeah, I was thinking about that this morning. That would help in another way: instead of the commit status update 'guessing' which credentials to use, the proper one could be explicitly selected.

@dhendo
Copy link

dhendo commented Feb 18, 2013

Ah right, I think this explains why when I built latest from source, I couldn't find anywhere to set the global/project config (as I don't use the github plugin managed webhooks, just polling). This may also be the cause of JENKINS-15787

@dhendo
Copy link

dhendo commented Feb 18, 2013

Rolled back to v1.5:

  • Set to auto manage webhooks, added credentials. Verified OK
  • Github project field now appears in the job config page. Set correct value.

Updated to latest:

  • Built latest plugin from master
  • Uploaded via the plugins advanced config
  • Restarted

Logged:
18-Feb-2013 16:49:30 hudson.util.CopyOnWriteList$ConverterImpl unmarshal
WARNING: Failed to resolve class
com.thoughtworks.xstream.mapper.CannotResolveClassException: com.coravy.hudson.plugins.github.GithubProjectProperty : com.coravy.hudson.plugins.github.GithubProjectProperty
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:68)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:71)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:86)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:96)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at hudson.util.XStream2$CompatibilityMapper.realClass(XStream2.java:231)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at hudson.util.xstream.MapperDelegate.realClass(MapperDelegate.java:43)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:56)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:70)
at hudson.util.CopyOnWriteList$ConverterImpl.unmarshal(CopyOnWriteList.java:193)
at hudson.util.CopyOnWriteList$ConverterImpl.unmarshal(CopyOnWriteList.java:172)
at hudson.util.XStream2$AssociatedConverterImpl.unmarshal(XStream2.java:313)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
at hudson.util.RobustReflectionConverter.unmarshalField(RobustReflectionConverter.java:333)
at hudson.util.RobustReflectionConverter.doUnmarshal(RobustReflectionConverter.java:275)
at hudson.util.RobustReflectionConverter.unmarshal(RobustReflectionConverter.java:222)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:137)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:926)
at hudson.util.XStream2.unmarshal(XStream2.java:104)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:912)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:864)
at hudson.XmlFile.read(XmlFile.java:137)
at hudson.model.Items.load(Items.java:220)
at jenkins.model.Jenkins$17.run(Jenkins.java:2539)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at jenkins.model.Jenkins$7.runTask(Jenkins.java:889)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)

I also get an unreadable data warning in the UI:

hudson.model.FreeStyleProject TMS-BRANCH CannotResolveClassException: com.coravy.hudson.plugins.github.GithubProjectProperty : com.coravy.hudson.plugins.github.GithubProjectProperty

@kpfleming
Copy link
Contributor

That's quite strange, as the project property code hasn't been touched in a while (in fact, it isn't even used for much in the plugin right now except putting a link on the project page). I haven't populated that property on any of my projects.

@pangratz
Copy link

Any updates on when this will be available? 😊

@addisonj
Copy link

I should mention. I have been running this at my workplace for a few weeks now.

We do use the plugin to manage service hooks, so it worked fine.

The only thing that is really missing to make this a solution to compete with travis-ci is pull-request hook, so that tests are run when a new pull request is opened.

@ludofleury
Copy link

Any update ? We need this badly.

@JaviSoto
Copy link

+1

@timmow
Copy link

timmow commented Apr 16, 2013

@addisonj have you seen the pull request builder plugin? https://wiki.jenkins-ci.org/display/JENKINS/Github+pull+request+builder+plugin

@peterfortuin
Copy link

I also tried to build the latest version of the plugin and I get the same stacktrace as dhendo.

Apr 27, 2013 12:10:03 AM hudson.util.CopyOnWriteList$ConverterImpl unmarshal
WARNING: Failed to resolve class
com.thoughtworks.xstream.mapper.CannotResolveClassException: com.coravy.hudson.plugins.github.GithubProjectProperty
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:56)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at hudson.util.XStream2$CompatibilityMapper.realClass(XStream2.java:255)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at hudson.util.xstream.MapperDelegate.realClass(MapperDelegate.java:43)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:49)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:70)
at hudson.util.CopyOnWriteList$ConverterImpl.unmarshal(CopyOnWriteList.java:193)
at hudson.util.CopyOnWriteList$ConverterImpl.unmarshal(CopyOnWriteList.java:172)
at hudson.util.XStream2$AssociatedConverterImpl.unmarshal(XStream2.java:337)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at hudson.util.RobustReflectionConverter.unmarshalField(RobustReflectionConverter.java:333)
at hudson.util.RobustReflectionConverter.doUnmarshal(RobustReflectionConverter.java:275)
at hudson.util.RobustReflectionConverter.unmarshal(RobustReflectionConverter.java:222)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1061)
at hudson.util.XStream2.unmarshal(XStream2.java:109)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1045)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:925)
at hudson.XmlFile.read(XmlFile.java:143)
at hudson.model.Items.load(Items.java:220)
at jenkins.model.Jenkins$17.run(Jenkins.java:2537)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at jenkins.model.Jenkins$7.runTask(Jenkins.java:888)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

The strange thing is that the class in mention com.coravy.hudson.plugins.github.GithubProjectProperty is there. So, I have no idea why he can't find it.

@ndeloof ndeloof deleted the commit-status-api branch May 8, 2013 05:49
@dhendo
Copy link

dhendo commented May 20, 2013

Ok, so I've got this working now:

  • I updated to the released version of 1.6.
  • I finally got the port forwarding setup so that I could use push-based build triggering rather than polling

I strongly suspect that having the latter setup correctly caused the commit status API to start working correctly. Other than the port forwarding / firewalling setup (Github IPs here: https://help.github.com/articles/what-ip-addresses-does-github-use-that-i-should-whitelist) there are no major downsides to moving to push-based.

@ludofleury
Copy link

@dhendo basically I didn't get you, this feature is available in 1.6 ?
Any docs about how to config ?

@dhendo
Copy link

dhendo commented May 28, 2013

@ludofleury yes, it now works fine for me in version 1.6.
Previously I was using polling rather than using the Github hook to trigger builds.

Setup Steps:

  • Install plugin
  • In "Configure System", make sure that "Let Jenkins auto-manage hook URLs" is selected.
  • Enter a github username & password. Test credentials.
    For each job that you want the build status applied to:
  • Set the correct Github Project
  • Check "Build when a change is pushed to GitHub" under build triggers
  • Add a post-build action "Set build status on Github commit"

In your github account, setup the Jenkins hook.

With this set up, builds are now triggered by pushed to github, commit SHAs are linked to github and the status of each commit is written to github.

@ludofleury
Copy link

@dhendo Hey, yes I didn't notice the "Set build status on Github commit", it works like a charm, just need some documentation on it on the jenkins plugin page maybe.

  1. I was not sure about the "api key vs password" in the global configuration. The notification requires the password?
  2. Once you select the "Set build status on Github commit" you can't delete this notifier. You have to remove it from the xml config of the job, could be annoying.
  3. Is it possible to notify the pending state when we start a build ? I had to manually do this with gcli in the beginning of the build
gcli status create MyOrganization MyRepository $GIT_COMMIT --state="pending" --target=$BUILD_URL --desc="Build #$BUILD_NUMBER is running" --format="csv"
  1. As in my previous example, any chance to be allowed to custom the commit message, actually it's "Success: Success" or "Failed: failed", The build number is somewhat useful.

But, thanks you very much for your work, we needed this and it's already really handy.

@mnapoli
Copy link

mnapoli commented May 28, 2013

  1. I was not sure about the "api key vs password" in the global configuration. The notification requires the password?

From the docs:

You'll specify GitHub user names and passwords so that Jenkins can login as you to do this, and yes, we need your password and not API token because GitHub doesn't have an API for managing post-commit hooks.

I don't understand how to use the API key too, it seems the password is the only option.

  1. Once you select the "Set build status on Github commit" you can't delete this notifier. You have to remove it from the xml config of the job, could be annoying.

I have a "delete" button for this notifier, I can delete it without problems.


On my install I have everything set up as it has been said, but still no luck in commit status. The only difference is that I used "Manually manage hook URLs" instead of "Let Jenkins auto-manage hook URLs" (I didn't want to leave my password in there).
Building on push works, but I don't see any build status appearing anywhere (yes I have "Set build status on Github commit"). But my build is currently failing, are post-build actions executed when the build is failing?

@dhendo
Copy link

dhendo commented May 28, 2013

@mnapoli AFAIK, the commit status API needs a username and password to set the status. From what I saw, it also doesn't work if you have it set to "Manually manage hook URLs"

To avoid username/password authentication, it looks like we'd need to use OAuth: https://github.com/blog/1090-github-api-moving-on

@mnapoli
Copy link

mnapoli commented May 28, 2013

@dhendo Thanks, then I know what's wrong, I'll see to change the set up.

@ludofleury
Copy link

@mnapoli could you screenshot me your delete button lol. cause I don't have it ?

@mnapoli
Copy link

mnapoli commented May 28, 2013

There you go:

capture decran 2013-05-28 a 14 23 37

Jenkins 1.515 (fresh install from 2 days ago)
GitHub plugin 1.6

@ludofleury
Copy link

@mnapoli Damn, maybe a conflict with some other displayed plugins... don't have the button. Thanks much

@peterfortuin
Copy link

Apparently username/password authentication is not a option any more. Does anybody have the build status on Github working with OAuth token?

@dhendo
Copy link

dhendo commented Nov 28, 2013

Yes, I got a Personal OAuth token to use with it.

Settings -> Applications -> Personal Access Tokens

@peterfortuin
Copy link

Ok. Then I have no idea what is going wrong in my case. I have created a access token and added that to my Jenkins settings. Jenkins says that the authentication was successful. At the end of the build I see the following message:

Setting commit status on GitHub for https://github.com/peerke/OutdoorPuzzleGame/commit/599bcbcb8315bcf7f0955d1b3bbaacf9cfa2d1ce
(the url is automatically changed into a link her with the GitHub formatting)

I don't see anything in the commit on GitHub. What am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.