Git clone cannot merge when PR build is triggered from api


#1

Hi,

Im trying to great a PR from VSTS (since they are no yet supported : Pull Request support for AzureDevOps (VSTS))
A PR build will be triggered in Bitirse using the api when needed. the api request will look like this :

{
  "hook_info": {
    "type": "bitrise",
    "build_trigger_token": "..."
  },
  "build_params": {
    "branch": "feature/testPr",
    "workflow_id": "ci",
    "branch_dest": "develop",
    "pull_request_id": 12345,
  }

}

That 'c’i workflow works without any problem with a simple trigger (in the dashboard or even in the api when branch_dest & pull_request_id are not passed ).
But following that request this is the result : it’s obviously a merge issue, but that feature/testPr branch have minimal change and it merge gracefully with develop without any problem in my machine.

git "init"
Initialized empty Git repository in /Users/vagrant/git/.git/
git "remote" "add" "origin" "myorganization@vs-ssh.visualstudio.com:v3/myorganization/myproject/myrepo"
git "fetch" "origin" "develop"
Warning: Permanently added 'vs-ssh.visualstudio.com,XX.XX.XX.XX' (RSA) to the list of known hosts.
From vs-ssh.visualstudio.com:v3/myorganization/myproject/myrepo
 * branch              develop    -> FETCH_HEAD
 * [new branch]        develop    -> origin/develop
git "checkout" "develop"
Switched to a new branch 'develop'
Branch 'develop' set up to track remote branch 'develop' from 'origin'.
Already up to date.
commit hash: 123c....8
git "fetch" "origin" "feature/testPr"
Warning: Permanently added 'vs-ssh.visualstudio.com,XX.XX.XX.XX' (RSA) to the list of known hosts.
From vs-ssh.visualstudio.com:v3//myorganization/myproject/myrepo
 * branch              feature/testPr -> FETCH_HEAD
 * [new branch]        feature/testPr -> origin/feature/testPr
git "merge" ""
merge:  - not something we can merge
ERROR: manual merge, error: merge failed (), error: exit status 1

I tried to alternate Manual merge setting between yes and no but ti fails anyway : (the following is when is set to yes)

git "init"
Initialized empty Git repository in /Users/vagrant/git/.git/
git "remote" "add" "origin" "myorganization@vs-ssh.visualstudio.com:v3/myorganization/myproject/myrepo"
git "fetch" "origin" "develop"
Warning: Permanently added 'vs-ssh.visualstudio.com,XX.XX.XX.XX' (RSA) to the list of known hosts.
commit hash: 123c....8
git "fetch" "origin" "feature/testPr"
Warning: Permanently added 'vs-ssh.visualstudio.com,65.52.8.37' (RSA) to the list of known hosts.
From vs-ssh.visualstudio.com:v3//myorganization/myproject/myrepo
 * branch              feature/testPr -> FETCH_HEAD
 * [new branch]        feature/testPr -> origin/feature/testPr
git "merge" ""
merge:  - not something we can merge
ERROR: manual merge, error: merge failed (), error: exit status 1

Any idea how I can make this work ?


#2

Hi @aladdinG!

Can you please include a build URL we could take a look at as well?


#3

@bitce here you go ttps://app.bitrise.io/build/f6d3e89e584d58b8


#4

Hello @aladdinG!

Could you try with clone depth set to 1?


#5

Is not working.

With Auto Merge Yes : https://app.bitrise.io/build/0df310ce8745c7c8
With Auto Merge No : https://app.bitrise.io/build/0d2cec7119e77270


#6

Any status for this issue?


#7

Hi @aladdinG,

git "merge" ""
merge: - not something we can merge

The error messages above shows that the merge command does not receive a valid branch name: it gets an empty string.

It isn’t trivial, but this branch argument comes from a commit environment variable, which ultimately comes from a commit_hash parameter in the request body. The underlying layers use the Bitrise Trigger API. I linked the relevant lines in the source code and some docs below.

Let me know if this helps! :slight_smile:

Links:


#8

thank you @laszlo.szucs. Actually it did help. I had to specify the commit_hash instead to make it work.
I’ts look like if this context the branch is ignored or something when it’s a PR merge it just ignore the branch and only take the commit_hash ?
If it’s the case the documentation in https://devcenter.bitrise.io/api/build-trigger/#pull-request-specific need to be updated/fixed … Or maybe I missed something ?


#9

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.