簡體   English   中英

TFS2018為什么架子集名稱為空?

[英]TFS2018 why is shelveset name empty?

當使用TFS2018手動對構建進行排隊時,架子集名稱在所有情況下都不會顯示源分支名稱。 有時填寫,有時不填寫。 由於我正在為源分支$(Build.SourceBranch)$(Build.SourceBranchName)選擇構建變量

如果Shelveset名稱為空,它們將為空。

在此處輸入圖片說明

創建構建定義時,是否可以使用API​​將貨架集名稱默認設置為源分支?

是否可以使用另一個構建變量來獲取當前構建的解決方案的源路徑?

更新因此,我正在嘗試使用build api更新源分支。 但是,當我打電話給我

{StatusCode:405,ReasonPhrase:“不允許使用方法”,版本:1.1,內容:System.Net.Http.StreamContent,標頭:{Pragma:無緩存X-TFS-ProcessId:ActivityId:X-TFS-Session:X -VSS-E2EID:X-幀選項:SAMEORIGIN X-VSS-UserData::user持久身份驗證:true Lfs-身份驗證:NTLM X-Content-Type-Options:nosniff緩存控制:no-cache日期:Fri, 2018年3月9日14:37:16 GMT P3P:CP =“ CAO DSP COR ADMA DEV CONo TELo CUR PSA PSD TAI IVDo我們的SAMI BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT”服務器:Microsoft-IIS / 10.0 X -AspNet-版本:4.0.30319 X-Powered-由:ASP.NET內容長度:93允許:GET內容類型:application / json; charset = utf-8過期:-1}}

對於以下代碼....

internal void UpdateSourceBranches(List<BuildDefinition> defs)
        {
            using (var handler = new HttpClientHandler { Credentials = new NetworkCredential(tfsUser, tfsPass) })
            using (var client = new HttpClient(handler))
            {
                try
                {
                    client.BaseAddress = new Uri(tfsServer);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    foreach (var def in defs)
                    {
                        var buildId = def.Id;
                        var sourceBranch = $"$/{def.Repository.Name}/{def.Project.Name}";
                        var parameters = new Dictionary<string, string> { { "BuildConfiguration", "release" },
                        { "BuildPlatform", "x86|x64|ARM" },
                        { "system.debug", "true" }
                    };

                        var jsonParams = JsonConvert.SerializeObject(parameters);

                        var content = new FormUrlEncodedContent(new[]
                        {
                            new KeyValuePair<string, string>("id", buildId.ToString()),
                            new KeyValuePair<string, string>("sourceBranch", sourceBranch),
                            new KeyValuePair<string, string>("parameters", jsonParams)
                        });

                        var response = client.PostAsync($"DefaultCollection/{def.Repository.Name}/_apis/build/builds?api-version=3.0-preview.1", content);
                        var s = response.Result;
                    }                  
                }
                catch (Exception ex)
                {

                }

            }
        }

您應該使用Queue構建 API來設置SourceBranch,例如:

POST http://TFS2018:8080/tfs/DefaultCollection/{project}/_apis/build/builds?api-version=2.0

Content-Type: application/json

{
  "definition": {
    "id": 47
  },
  "sourceBranch":"$/CeceScrum/TestCaseProject",
  "parameters":"{\"BuildConfiguration\":\"release\",\"BuildPlatform\":\"any cpu\",\"system.debug\":\"false\"}"
}

如果要選擇要構建的貨架集,則api如下所示:

POST http://TFS2018:8080/tfs/DefaultCollection/{project}/_apis/build/builds?api-version=2.0

    Content-Type: application/json

    {
      "definition": {
        "id": 47
      },
      "sourceBranch":"ceceShelveset;domain\\username",
      "parameters":"{\"BuildConfiguration\":\"release\",\"BuildPlatform\":\"any cpu\",\"system.debug\":\"false\"}"
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM