[ad_1]
I have a manual process I am looking to automate.
This process consists of
-
Going to a DevOps Project
-
Go to Repos > Files > a sub sub folder and Create a New Branch from here, based on main
-
Commit the file
-
Submit a pull request
This, when committed and the pull is done from this folder, starts a pipeline.
I have a flow which currently
-
does a GET request on
https://dev.azure.com/<org name>/<project name>/_apis/git/repositories/<repo id>/refs?filter=heads/main&api-version=5.1
which brings back the objectID for main on this repo.
-
Using the objectID from the GET, does a POST on
https://dev.azure.com/<org name>/<proj name>/_apis/git/repositories/<repo id>/pushes?api-version=5.1
with body of
"refUpdates": [
{
"name": "refs/heads/<name of new branch>",
"oldObjectId": "<objectID from GET command"
}
],
"commits": [
{
"comment": "<any name we give the file>",
"changes": [
{
"changeType": "add",
"item": {
"path": "/<Filename>.json"
},
"newContent": {
"content": '<our JSON content>',
"contentType": "rawtext"}
}
]
}
]
}
-
Then does a pull request on this file using POST of
https://dev.azure.com/<org ID>/<proj name>/_apis/git/repositories/<repo ID>/pullrequests?api-version=5.1
with a body of
```{"sourceRefName": "refs/heads/<our branch name we set in the POST>", "targetRefName": "refs/heads/main", "title": "<our title>", "description": "", "reviewers": [{"id": "<the ID for our approval team>"}]} ```
The above ‘works’ in as much as it does the steps I think I am telling it, and creates a branch for me, adds the file and it’s content, and does the pull request.
However, the instructions I have been given for DevOps itself, show that I need to go to a sub-path within the repo I am using, of 4 folders down in the files area of Repos, and create a new branch in there; then add the file to this branch, Commit it and do the pull request from here. This then, when the pull request is approved, triggers a pipeline.
I just don’t know where I can specify this sub sub folder for the branch to be created, and then have the file created on this branch from a sub sub folder…. and then do the pull request on this branch into main.
[ad_2]