简体   繁体   English

以编程方式创建 Azure DevOps 工件

[英]Creating Azure DevOps Artifact programmatically

Need to create a Azure DevOps GitHub Artifact programmatically.需要以编程方式创建 Azure DevOps GitHub工件 I'm using.Net Client Libraries and tried the following code.我正在使用.Net 客户端库并尝试了以下代码。

var artifactMetaData = new ArtifactMetadata { Alias = "ArtiAlias", InstanceReference = new BuildVersion { Id = "32q42324QQe1" } };

The Id I'm refering here is the commit Id of a Git Repo.我在这里指的 Id 是 Git Repo 的提交 Id。

I could create Build Artifacts successfully using the above code but it doesn't create GitHub Artifacts.我可以使用上面的代码成功创建构建工件,但它不会创建 GitHub 工件。

Was able to check REST API call using Postman and create the ArtifactMetaData object as same as the REST API object (in request body). Was able to check REST API call using Postman and create the ArtifactMetaData object as same as the REST API object (in request body). Then the problem was solved.然后问题就解决了。

REST API Request Body, REST API 请求正文,

{
  "alias": "MyRepo",
  "instanceReference": {
                "id": "r32283026ewec1c63b0842a58w2aa0a690a58265",
                "name": "r3228302",
                "sourceBranch": "feature/my-feature-branch",
                "commitMessage": "My commit message"
            }
}

C# object I created, C# object 我创建的,

var artifactMetadata = new ArtifactMetadata
                    {
                        Alias = "MyRepo",
                        InstanceReference = new BuildVersion
                        {
                            Id = "r32283026ewec1c63b0842a58w2aa0a690a58265",
                            Name = "r3228302",
                            SourceBranch = "feature/my-feature-branch",
                            CommitMessage = "My commit message"
                        }
};,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM