0
votes

I am trying to merge a branch using the NodeJS SDK for the Azure DevOps REST API.

I have the following typescript code using the Azure DevOps Node SDK (https://www.npmjs.com/package/azure-devops-node-api)

  // get master commit
  const masterRef = (await gitApi.getRefs(repository.id!, devOps.projectName, 'heads/master'))[0];

  // merge branch into master
  let merge = await gitApi.createMergeRequest(
    {
      comment: 'Merge',
      parents: [branchLatestCommitId, masterRef.objectId!]
    },
    devOps.projectName,
    repository.id!
  );

And I can see in the console when I print the result of the merge object (with a status of 3, indicating Completed):

Object
comment: "Merge"
detailedStatus: {mergeCommitId: "faaeb4adef7640d9dac56592ef96e2535dd46078"}
mergeOperationId: 38
parents: (2) ["67f62907ec3ab10afc8452a649bf010e02d38af9", "8ac25ac12c7e9b28195aa64ed7a23d3939a3491d"]
status: 3
__proto__: Object

Alas...nothing has changed in my git repository. The branch is still there, unmerged into master.

1
Do you mean the REST API was executed successfully, but the branch was not merged? is it? So, are the commits on the branch merged into the target branch? Can you see the commits from the merge branch on your target branch?Leo Liu-MSFT
Correct - I see no indications that the merge was actually performed when I look at the git repository. And further that “mergeCommId” doesn’t even exist in the repositoryJeff
Thanks for your quickly reply. Are you executing the above code in the pipeline or in the local?Leo Liu-MSFT
Locally using a node appJeff

1 Answers