[JIRA] (JENKINS-54956) Github merge refs not working correctly

2 views
Skip to first unread message

jraezrus@cloudbees.com (JIRA)

unread,
Nov 30, 2018, 2:38:01 AM11/30/18
to jenkinsc...@googlegroups.com
Javier Raez created an issue
 
Jenkins / Bug JENKINS-54956
Github merge refs not working correctly
Issue Type: Bug Bug
Assignee: Unassigned
Components: github-branch-source-plugin
Created: 2018-11-30 07:37
Priority: Minor Minor
Reporter: Javier Raez

We're having some issues where some of our developer's pull requests are not reporting that the "Jenkinsfile not found" when we know that their branch does indeed have the Jenkinsfile.

We first noticed it with GitHub webhooks that trigger the event when there is a change to the pull request.. that also reports "Jenkinsfile not found". Here is a snippet of the log: 
``` 
[Fri Nov 23 09:13:55 PST 2018] Pull request #35771 updated in repository Safe/fme UPDATED event from xxx.xxx.xxx.xx → xxx.xxx.xxx.xx → xxx.xxx.xxx.xx⇒ http://xxxxx/github-webhook/ with timestamp Fri Nov 23 09:13:48 PST 2018 processed in 2 sec 
[Fri Nov 23 09:27:55 PST 2018] Received Pull request #35897 opened in repository Safe/fme CREATED event from xxx.xxx.xx.xxx → xxx.xxx.xxx.xxx → xxx.xxx.xxx.xx ⇒ xxxxxxxxx/github-webhook/ with timestamp Fri Nov 23 09:27:50 PST 2018
09:27:56 Connecting to http://xxxxxx/api/v3 using bbuilder/****** (Bob the Builder's Credentials) 
Examining Safe/fme

Checking pull-requests...

Getting remote pull request #35897...

Checking pull request #35897 
‘jenkins/Jenkinsfile’ not found 
Does not meet criteria

Checking pull request #35897 
‘jenkins/Jenkinsfile’ not found 
Does not meet criteria

2 pull requests were processed

Finished examining Safe/fme 
```

We then tried to use the "Scan Repository Now" feature to see if it would find it then.. but that also failed.

We dug into the plugin source code and found that it was trying to access this API endpoint on GitHub:

http://xxxxxxx/api/v3/repos/Safe/fme/contents/jenkins?ref=pull/35897/merge

The response from that API call was this:

``` 

{  "message": "No commit found for the ref pull/35897/merge",  "documentation_url": "[https://developer.github.com/enterprise/2.14/v3/repos/contents/]"  }

 
```

After some time, the API somehow refreshed and it now properly returns the right contents and the pipeline is now working for that pull request.

 

Aparently this API call to get the '/merge' refs is an undocumented feature and not fully supported by GitHub.

http://xxxxxxxx/api/v3/repos/Safe/fme/contents/jenkins?ref=pull/35897/merge

Here is their response to that:

---------------------------------- 
Hi xxxx,

The /merge refs are an undocumented feature and we don't recommend relying on them as they're subject to change at anytime. This feature was built to power the Pull Requests feature in the GitHub Web UI, it was not built to be used by 3rd party services or tooling such as an API.

As this is undocumented, you should not have any expectations about the behavior, the behavior might change at any time and those refs might completely go away without warning. In our current implementation, the pull/*/merge reference should be eventually updated when either the head or base branch of the pull request being pushed to. This happens in the background that is run asynchronously and GitHub Enterprise does not guarantee that it will be available at any specific time after a pull request's head branch is pushed to.

It's also possible for the merge ref to be missing or point to an out-of-date merge; for example, if the latest push to a branch causes a merge conflict.

Again, we do not recommend relying on this ref and instead recommend you update your jobs to use the head branch. For example:

http://xxxxxx/api/v3/repos/Safe/fme/contents/jenkins?ref=pull/35897/head 
This should always be available after a push completes. If you'd like to test the result of a merge with the base branch, your CI server can either perform the merge locally, or you can [configure a required status check with the strict policy](https://help.github.com/enterprise/2.14/user/articles/types-of-required-status-checks/, which will ensure that the head branch is always up-to-date with respect to the base before merging is allowed.

Let us know how that works for you and please do not hesitate to reach out with any further questions.

Thanks,

Brian 
----------------------------------

With that, it seems the GitHub Branch Source Plugin is may not be very reliable and could potentially break at anytime. 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

thomas@deepomatic.com (JIRA)

unread,
Jan 29, 2019, 10:32:02 AM1/29/19
to jenkinsc...@googlegroups.com
Thomas Riccardi commented on Bug JENKINS-54956
 
Re: Github merge refs not working correctly

We encountered the same issue. After 5h on github.com the `/merge` ref is still unavailable it seems...

The only workaround was to create a new PR.

I tested:

  • closing/reopening
  • pushing new commits
  • waiting 4h

According to github it should eventually converge, maybe we should loop wait on jenkins side? But 4h is long, maybe there is a deadlock on github side when on github the branch is protected by waiting for jenkins CI status?

Suggestion: at least the jenkins plugin should log something different than `‘Jenkinsfile’ not found`. Maybe an explicit explanation linking to here, and document the workaround: create a new PR.

bitwiseman@gmail.com (JIRA)

unread,
May 3, 2019, 8:34:02 PM5/3/19
to jenkinsc...@googlegroups.com
Liam Newman started work on Bug JENKINS-54956
 
Change By: Liam Newman
Status: Open In Progress

bitwiseman@gmail.com (JIRA)

unread,
May 3, 2019, 8:47:02 PM5/3/19
to jenkinsc...@googlegroups.com

Thomas Riccardi, Javier Raez
4h is particularly long.

That email if very confusing. I guess it is technically true, 'refs/pulls/nnnn/merge' is not specifically documented, but multiple things related to it are.
Merge_commit_sha and refs/pulls/nnnn/head are directly connected to this and have documentation.
https://developer.github.com/v3/pulls/#get-a-single-pull-request (see response).

Could you try out github branch source plugin v2.5.1. This may address this issue for you - or it may make the situation more extreme.

bitwiseman@gmail.com (JIRA)

unread,
May 3, 2019, 8:49:02 PM5/3/19
to jenkinsc...@googlegroups.com
Liam Newman edited a comment on Bug JENKINS-54956
[~thomas_deepomatic], [~jraezrus]

4h is particularly long.

That email if very confusing. I guess it is technically true, 'refs/pulls/nnnn/merge' is not specifically documented, but multiple things related to it are.
{{Merge_commit_sha}} and {{refs/pulls/nnnn/head}} are directly connected to this and have documentation.
https://developer.github.com/v3/pulls/#get-a-single-pull-request (see response).

Could you try out github branch source plugin v2.5.1. This may address this issue for you - or it may make the situation works more extreme deeply but also in a more accurate way with these APIs .   If nothing else, it would be very useful to have more data from  the current version of the plugin.

bitwiseman@gmail.com (JIRA)

unread,
May 29, 2019, 2:35:01 PM5/29/19
to jenkinsc...@googlegroups.com

Javier RaezThomas Riccardi
Could you try out github branch source plugin v2.5.3?

I'm going to resolve this this due to lack of response. We can reopen if it still occurring.

bitwiseman@gmail.com (JIRA)

unread,
May 29, 2019, 2:36:03 PM5/29/19
to jenkinsc...@googlegroups.com
Liam Newman resolved as Cannot Reproduce
 
Change By: Liam Newman
Status: In Progress Resolved
Resolution: Cannot Reproduce
Reply all
Reply to author
Forward
0 new messages