有没有一种方法可以自动从现有的YAML设置Azure DevOps流水线?

huangapple go评论64阅读模式
英文:

Is there a way to automatically setup the azure devops pipeline from existing YAML?

问题

I have a few YAML files already hosted on a devops repo. Is there any way to automatically create a devops pipeline from these YAML files and not go through the wizard of setting up the pipeline.

This situation will also arise while setting up a new repo. I'm setting up tenancy for my platform and need to automatically set up a few pipelines when I bootstrap the repo.

Don't want to go through the below wizard to set up the pipeline.

英文:

I have a few YAML file already hosted on devops repo. Is there any way to automatically create devops pipeline from these YAML file and not go through the wizard of setting up the pipeline.

This situation will also arise while setting up a new repo. I'm setting up tenancy for my platform and need to automatically setup a few pipelines when i bootstrap the repo.

Don't want to go through the below wizard to setup the pipeline:

有没有一种方法可以自动从现有的YAML设置Azure DevOps流水线?

答案1

得分: 1

You can automate it with Rest API.
使用 Pipelines - Create

POST https://dev.azure.com/{organization}/{project}/_apis/pipelines?api-version=7.1-preview.1

一个示例请求体:

$body = @{
  configuration=@{
    variables=@{
      customVariable=@{
        value="value"
      }
    };
    path="azure-pipelines.yml";
    repository=@{
      id= "repository-id";
      name="repository-name";
      type= "azureReposGit";
    };
    type= "yaml"
  };
  name= "pipeline-name";
  folder= "\\"
}
英文:

You can automate it with Rest API.
Use the Pipelines - Create:

POST https://dev.azure.com/{organization}/{project}/_apis/pipelines?api-version=7.1-preview.1

An example to body:

$body = @{
  configuration=@{
                    variables=@{
                                customVariable=@{
                                        value="value"
                                }
                    };
                    path="azure-pipelines.yml";
                    repository=@{
                                    id=  "repository-id";
                                    name="repository-name"
                                    type=  "azureReposGit"
                                  };
                    type=  "yaml"
       };
   name=  "pipeline-name";
   folder= "\\"
 }

huangapple
  • 本文由 发表于 2023年5月11日 18:52:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76226831.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定