Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Github PR build fails to start #3966

waldemar ·

I am having hard time diagnosing problem with QB failing to start a build in response to a Github PR. I have setup repository of type 'github' and entered proper credentials and urls. It is configured to look for 'all open requests' with Type: MERGE. It appears QB can reach github just fine. It detects correct open Pull Request and tries to build it but it fails with:

Caused by: com.pmease.quickbuild.QuickbuildException: Failed to run command: git fetch origin refs/pull/2/merge -q

I was checking the agent where the build was to run but I could not find any repositories in the workspace. I would think, QB must have cloned it somewhere first before attempting to run 'git fetch' but I don't know where this could be. Trying the same 'git fetch origin refs/pull/2/merge' on another machine succeeds.

What is the best approach to finding the problem?

  • replies 6
  • views 1870
  • stars 0
robinshen ADMIN ·

This command should be run on the node running the master step. Please node log (server log or agent log) to see if there are any additional errors along side this error.

waldemar ·

Here's the log from the agent. I see another error, it is marked as "warning":

jvm 1 | 2018-07-12 01:43:46,339 WARN - Repository RC file /opt/qb/buildagent/workspace/2573/rel_xxx_merge/.qbcache/qb-scm.xml doesn't exist!

Of the four repositories that it is fetching only the first one, test_xxx_cm, is of type "github". The remaining ones are type "git".

This error refers to a repository that is not supposed to be fetched on this node. This repository is fetched in a step that runs on a different node. This works fine if we run it with all repositories of type "git" (including test_xxx_cm) but it somehow fails now that we changed test_xxx_cm to "github" to be able to run against Github PR.

jvm 1    | 2018-07-12 01:43:41,719 INFO  - snapshot taking on: qba16  exec: install_github_ssh_keys
jvm 1    | 2018-07-12 01:43:43,377 INFO  - Taking snapshot of repository 'test_xxx_cm'...
jvm 1    | 2018-07-12 01:43:43,379 INFO  - Determining head revision for repository: test_xxx_cm
jvm 1    | 2018-07-12 01:43:44,876 INFO  - Taking snapshot of repository 'rel_xxx_scripts'...
jvm 1    | 2018-07-12 01:43:44,877 INFO  - Determining head revision for repository: rel_xxx_scripts
jvm 1    | 2018-07-12 01:43:45,630 INFO  - Taking snapshot of repository 'rel_xxx_certs'...
jvm 1    | 2018-07-12 01:43:45,631 INFO  - Determining head revision for repository: rel_xxx_certs
jvm 1    | 2018-07-12 01:43:46,335 INFO  - Taking snapshot of repository 'rel_xxx_merge'...
jvm 1    | 2018-07-12 01:43:46,337 INFO  - Determining head revision for repository: rel_xxx_merge
jvm 1    | 2018-07-12 01:43:46,339 WARN  - Repository RC file /opt/qb/buildagent/workspace/2573/rel_xxx_merge/.qbcache/qb-scm.xml doesn't exist!
jvm 1    | 2018-07-12 01:43:46,341 INFO  - Repository does not exist, creating...
jvm 1    | 2018-07-12 01:43:47,084 ERROR - fatal: Couldn't find remote ref refs/pull/2/head
robinshen ADMIN ·

Have you specified different destination paths for different git repositories (both for normal git repository, and for GitHub repository)? If not, all repositories will clone to same directory to interfere with each other.

waldemar ·

Yes, the paths are different.

I reduced the problem by disabling all steps that checkout repositories except one, the first one that is type "github". With this single repository, the build starts. When I add just one other repository, which is of type "git", then it fails to start with the error as before. It looks as though QB may be trying to get refs/pull/2/head in the non-github repository.

I wonder if this has something to do with our snapshot taking script (set in Advanced Settings: Snapshot Taking). The script is like this:

groovy:
cmd='install_github_ssh_keys'
logger.info('snapshot taking on: ' + node.getHostName() + '  exec: ' + cmd)
assert util.execute(cmd) == 0, "Could not install keys"
for (repo in configuration.getReferencedRepositories()) {
    repo.takeSnapshot();
}

The log on server looks like this:

Caused by: java.lang.RuntimeException: Failed to evaluate below expression in configuration 'xxx/xxx/xxx':
    groovy:
    cmd='install_github_ssh_keys'
    logger.info('snapshot taking on: ' + node.getHostName() + ' exec: ' + cmd)
    assert util.execute(cmd) == 0, "Could not install keys"
    for (repo in configuration.getReferencedRepositories()) {
     repo.takeSnapshot();
    }
        at com.pmease.quickbuild.util.ExceptionUtils.wrapException(ExceptionUtils.java:87)
        at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:321)
        at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:74)
        at com.pmease.quickbuild.setting.configuration.snapshot.ScriptSnapshotTaking.takeSnapshot(ScriptSnapshotTaking.java:39)
        at com.pmease.quickbuild.model.Configuration.takeSnapshot(Configuration.java:1988)
        at com.pmease.quickbuild.CheckConditionJob.execute(CheckConditionJob.java:35)
        at com.pmease.quickbuild.grid.GridJob.run(GridJob.java:129)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        ... 3 more
    Caused by: com.pmease.quickbuild.QuickbuildException: Failed to run command: git fetch origin refs/pull/2/merge -q 
    Command return code: 128
    Command error output: fatal: Couldn't find remote ref refs/pull/2/merge

I also checked files on the agent. It looks like QB fetched both repositories successfully. The workspace of both repos was empty but .git existed in both repos. Running 'git fetch origin refs/pull/2/merge' in the "github" repository succeeded.

robinshen ADMIN ·
waldemar ·

Thank you so much. QB support is second to none!