web-dev-qa-db-ja.com

Visual Studio TeamServicesでのビルドが成功したときにソースにラベルを付ける方法

Visual Studio Team Services(XAMLではない)で新しいビルドを使用しようとしましたが、ビルドが成功したときにソースにラベルを付ける方法がわかりませんでした。何か案が?

以下は、XAML1で行う方法を示すスクリーンショットです。

enter image description here

私はすでに https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/9613014-allow-label-source-upon-succesful-build-on-visual で機能リクエストを持っています= Microsoftが実装するまで、実際に回避策を求めています。

10
cilerler

この機能がビルドvNextで利用できるようになったことに気づきました。その構成は、ビルド定義の[リポジトリ]タブにあります。

Labeling

16
Yves Dierick

Yves Dierickの答えは2015年10月に正しかったと思いますが、それ以降、VSTS画面のレイアウトは大幅に変更されました。最新バージョン(2017年2月現在)では、ビルド定義で[ソースの取得]タスクを選択し、上部の[表示詳細設定]を選択することで、成功したビルドにラベルを追加できます。 -右隅にあり、表示されるタグソースセクションの下にある成功時ラジオボタンを選択します。

それを見つけるのにしばらく時間がかかったので、他の誰かに役立つかもしれないと思いました。このオプションが「タグソース」の下にあり、「ラベル」という単語についてはまったく言及されていないことは役に立ちません。

enter image description here


2018年3月13日更新

彼らはこのページのレイアウトを再び微調整しましたが、どちらかといえばそれをより単純にしました、そして今オプションはより便利に「ラベルソース」と名付けられています。 Updated option for labelling builds

20

(VSOではなく)ホストされているTFSのソリューションを探しているこのスレッドを実行している方は、ビルドラベルのサポートがTFS 2015 Update 1で公開されていることに注意してください。 https://www.visualstudio.com/en- us/news/tfs2015-update1-vs.aspx

Update 1はまだ実行されていないため、確認できません。

編集:現在、アップデート1(および実際には2)を実行しており、ラベルビルドソースはオンプレミスで機能します。

3
TScott

ラベルソース機能は、vNextビルドでは使用できません。

[ソースのラベル付け]機能に加えて、[作業項目の関連付け]および[ビルドの失敗時に作業項目を作成する]機能も使用できません。

Microsoft UserVoiceサイトでそれに関する1つの機能リクエストを送信できます: https://visualstudio.uservoice.com/forums/121579-visual-studio/category/30925-team-foundation-server-visual-studio-オンライン

1
Vicky - MSFT

XAMLビルドはビルドの開始時にソースにラベルを付けましたが、vNextビルドはビルドの終了時にラベルを付けるようです。ビルド中にファイルを変更/チェックイン/ラベル付けしたため、気づきました。 vNextにビルドのラベルを付けると、チェックイン後にファイルに適用したラベルが前のバージョン(GetSourcesで使用されていたバージョン)に移動します。

しかし、どのログファイルにもvNextのラベルが表示されませんでした。私はそれを逃しましたか? vnextでラベル付けを無効にして、msbuildスクリプトで行う必要があります...

編集:vnextビルド定義でラベル付けを無効にし、ワークスペースのソースにラベルを付けるmsbuildインラインタスクを作成しました。これで、ビルドの開始時にすべてのソースにラベルを付け、ビルド中に変更されたファイルのラベルを移動できます:)

誰かが似たようなことをしたい場合、これが私のインラインタスクです:

<!--
    TaskName="LabelWorkspaceSources"
    - input: TfexeFullPath is the path to tf.exe
    - input: BaseDirectory is the mapped folder of the software to build
    - input: Label to apply
    - input: Version is the changeset to apply the label to
-->
<UsingTask TaskName="LabelWorkspaceSources" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
    <ParameterGroup>
        <TfexeFullPath Required="true" />
        <BaseDirectory Required="true" />
        <Label Required="true" />
        <Version Required="true" />
    </ParameterGroup>
    <Task>
        <Code Type="Fragment" Language="cs">
        <![CDATA[

        //--- get the workspace mapping ---

        System.Diagnostics.Process tfProcess = new System.Diagnostics.Process();
        tfProcess.StartInfo.FileName = TfexeFullPath;
        tfProcess.StartInfo.Arguments = "workfold";
        tfProcess.StartInfo.UseShellExecute = false;
        tfProcess.StartInfo.CreateNoWindow = true;
        tfProcess.StartInfo.RedirectStandardOutput = true;
        tfProcess.StartInfo.WorkingDirectory = BaseDirectory;
        tfProcess.Start();

        string output = tfProcess.StandardOutput.ReadToEnd();

        tfProcess.WaitForExit();

        string workfoldOutput = output.Trim();
        Log.LogMessage(workfoldOutput, MessageImportance.High);

        string[] linesWorkfoldOutput = workfoldOutput.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
        List<string> mappedFolders = new List<string>();

        Log.LogMessage("Trying to parse mapped folders.", MessageImportance.High);
        foreach (string line in linesWorkfoldOutput)
        {
            //e.g. $/TPA: C:\TFS_Source\TPA
            if (line.Contains("$/"))
            {
                string[] lineSplit = line.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries);

                //entry lineSplit[0] now contains the server path, lineSplit[1] contains the local folder
                mappedFolders.Add(lineSplit[1]);
                Log.LogMessage("Found mapped folder: " + lineSplit[1], MessageImportance.High);
            }
        }


        //--- label all the mapped folders ---

        foreach (string mappedFolder in mappedFolders)
        {
            tfProcess = new System.Diagnostics.Process();
            tfProcess.StartInfo.FileName = TfexeFullPath;
            tfProcess.StartInfo.Arguments = "label " + Label + " \"" + mappedFolder + "\" /child:replace /recursive /comment:\"Label created by task LabelWorkspaceSources\" /version:" + Version;
            tfProcess.StartInfo.UseShellExecute = false;
            tfProcess.StartInfo.CreateNoWindow = true;
            tfProcess.StartInfo.RedirectStandardOutput = true;
            tfProcess.StartInfo.WorkingDirectory = mappedFolder;
            tfProcess.Start();

            output = tfProcess.StandardOutput.ReadToEnd();

            tfProcess.WaitForExit();

            Log.LogMessage(tfProcess.StartInfo.Arguments, MessageImportance.High);
            Log.LogMessage(output, MessageImportance.High);
        }
        ]]>
        </Code>
    </Task>
</UsingTask>
0
PainElemental