I created a repo in azure, I created a bash file that cloned the repo from my CLI using:
$curl git clone https://username@dev.azure.com/organization/project/_git/reponame
which cloned the repo. My challenge now is automating the yaml file I have saved in my local machine, such that when I push, it goes to the remote repo and builds automatically. I would appreciate your ideas. Thanks
If you have not created an azure pipeline for your repo, then push the yaml file wont trigger a pipeline, since it doesnot exist.
If you intend to create your azure pipeline using curl request. You can call Build Definition Create restful api to create a pipeline via cli.
POST https://dev.azure.com/{organization}/{project}/_apis/build/definitions?api-version=5.1
See below script example:
Check here to get a personal access token .
You can call repository list rest api to get the id of your repository. You can also get the repository id for the UI (go to Project Settings --> Repositories under Repo --> select the your repository-->You will see the repository id in the address bar repositoryId=96a56858-..-...
)
curl -X POST \
-u username:personalaccesstoken https://dev.azure.com/{organization}/{project}/_apis/build/definitions?api-version=5.1 \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name" : "MyPipelineName";
"repository" : {
"url" : "<the-https-link-to-my-Git-repo>";
"defaultBranch" : "refs/heads/master";
"id" : "Id of the repository";
"type" : "TfsGit";
};
"process" : {
"yamlFilename": "path to/my-pipeline.yml";
"type" : 2;
};
"path": "\A New Folder";
"type" : "build";
}'
You can also create azure pipeline from your azure devops project UI portal. Please check the detailed steps here . Since you already have your yaml file. You can choose Existing Azure Pipeline YAML file
during the setting up wizard. See below:
To enable triggerring your pipeline automatically after your created your pipeline via above methods. You need to define triggers in your yaml file. See here for more information.
For below example: every push to master branch will trigger build on master branch.
trigger:
- master
Note: yaml file must exist in the branch to trigger a build against this branch.
You could use Azure DevOps CLI:
Then the related build will be ran.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.