[JIRA] (JENKINS-38674) GitHubCommitStatusSetter unusable in pipeline with multiple checkout steps

111 views
Skip to first unread message

lglickfield@circleup.com (JIRA)

unread,
Oct 3, 2016, 10:52:01 PM10/3/16
to jenkinsc...@googlegroups.com
Logan Glickfield created an issue
 
Jenkins / Bug JENKINS-38674
GitHubCommitStatusSetter unusable in pipeline with multiple checkout steps
Issue Type: Bug Bug
Assignee: Kirill Merkushev
Components: github-plugin
Created: 2016/Oct/04 2:51 AM
Priority: Major Major
Reporter: Logan Glickfield

We're using the Shared Libraries Plugin with our Jenkins Pipeline along with a checkout step.

Combined this means there are two separate checkouts when the pipeline runs.

When I then try to call a step with GitHubCommitStatusSetter, it then tries to set the status for both commits against both repositories (i.e. 4 different combinations of commit hash/repos). This results in {{FileNotFoundException}}s that fail the build. But this will obviously always fail because each commit is only valid for one of the repositories.

I see I can hardcode repository and sha values, but unfortunately with the Github Organizational plugin, I don't have access to the sha directly.

Is there anything that can be done to make this work? Thanks!

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

lanwen@yandex.ru (JIRA)

unread,
Oct 5, 2016, 5:28:01 AM10/5/16
to jenkinsc...@googlegroups.com

marc.sutter@camptocamp.com (JIRA)

unread,
Mar 31, 2017, 10:30:04 AM3/31/17
to jenkinsc...@googlegroups.com

Hi,

I had the same issue with Shared Library usage and come up with following workaround.

Note that this code is part of our shared library repo and that we pass the currentBuild variable to the 'updateGithubCommitStatus' function.

 

def getRepoURL() {
  sh "git config --get remote.origin.url > .git/remote-url"
  return readFile(".git/remote-url").trim()
}

def getCommitSha() {
  sh "git rev-parse HEAD > .git/current-commit"
  return readFile(".git/current-commit").trim()
}

def updateGithubCommitStatus(build) {
  // workaround https://issues.jenkins-ci.org/browse/JENKINS-38674
  repoUrl = getRepoURL()
  commitSha = getCommitSha()

step([
  $class: 'GitHubCommitStatusSetter',
  reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
  commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitSha],
  errorHandlers: [[$class: 'ShallowAnyErrorHandler']],
  statusResultSource: [
    $class: 'ConditionalStatusResultSource',
    results: [
      [$class: 'BetterThanOrEqualBuildResult', result: 'SUCCESS', state: 'SUCCESS', message: build.description],
      [$class: 'BetterThanOrEqualBuildResult', result: 'FAILURE', state: 'FAILURE', message: build.description],
      [$class: 'AnyBuildResult', state: 'FAILURE', message: 'Loophole']
      ]
    ]
  ])
}

 

This work fine for our needs.

Vheers

Marc

 

 

This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

marc.sutter@camptocamp.com (JIRA)

unread,
Mar 31, 2017, 10:31:02 AM3/31/17
to jenkinsc...@googlegroups.com
Marc Sutter edited a comment on Bug JENKINS-38674
Hi,

I had the same issue with Shared Library usage and
come came up with following workaround.


Note that this code is part of our shared library repo and that we pass the currentBuild variable to the 'updateGithubCommitStatus' function.

 
{code:java}

def getRepoURL() {
  sh "git config --get remote.origin.url > .git/remote-url"
  return readFile(".git/remote-url").trim()
}

def getCommitSha() {
  sh "git rev-parse HEAD > .git/current-commit"
  return readFile(".git/current-commit").trim()
}

def updateGithubCommitStatus(build) {
  // workaround https://issues.jenkins-ci.org/browse/JENKINS-38674
  repoUrl = getRepoURL()
  commitSha = getCommitSha()

step([
  $class: 'GitHubCommitStatusSetter',
  reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
  commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitSha],
  errorHandlers: [[$class: 'ShallowAnyErrorHandler']],
  statusResultSource: [
    $class: 'ConditionalStatusResultSource',
    results: [
      [$class: 'BetterThanOrEqualBuildResult', result: 'SUCCESS', state: 'SUCCESS', message: build.description],
      [$class: 'BetterThanOrEqualBuildResult', result: 'FAILURE', state: 'FAILURE', message: build.description],
      [$class: 'AnyBuildResult', state: 'FAILURE', message: 'Loophole']
      ]
    ]
  ])
}
{code}

 

This work fine for our needs.

Vheers

Marc

 

 

marc.sutter@camptocamp.com (JIRA)

unread,
Mar 31, 2017, 10:32:03 AM3/31/17
to jenkinsc...@googlegroups.com
Marc Sutter edited a comment on Bug JENKINS-38674
Hi,

I had the same issue with Shared Library usage and came up with following workaround.
This work works fine for our needs.

Vheers Cheers

Marc

 

 

marc.sutter@camptocamp.com (JIRA)

unread,
Mar 31, 2017, 10:32:03 AM3/31/17
to jenkinsc...@googlegroups.com
This work fine for our needs.

Vheers

Marc

 

 

lanwen@yandex.ru (JIRA)

unread,
Mar 31, 2017, 10:38:01 AM3/31/17
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages