How to limit build task only to VSTS not TFS

假装没事ソ 提交于 2019-12-13 17:16:14

问题


I have a VSTS extension with two build tasks, one build task should be available for both VSTS and TFS, the other one only for TFS. Is it possible to configure this for each build task via extension manifest?


回答1:


I have used the following workaround to display message and discontinue the build in TFS.

var collectionUrl = process.env["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"];
var regExpression = new RegExp("^((https?)\:\/\/)(([a-z0-9])+\.)*(visualstudio\.com)");
if(regExpression.test(collectionUrl))
{
    //VSTS Detected
}
else
{
   //Display message task not compatible with TFS
   //Fail the build
}



回答2:


Make the extension manifest indicates that the extension is available only for Team Services (targets = Microsoft.Visualstudio.Services.Cloud).




回答3:


There isn't any way to achieve this via extension manifest file. A good workaround is just as jessehouwing mentioned: Combine the two build tasks into one, provide an option in build setting to let user select or detect the build environment when running the build task. If TFS is selected or detected, run the code in the two build tasks, otherwise just run the code in the first build task.



来源:https://stackoverflow.com/questions/41499650/how-to-limit-build-task-only-to-vsts-not-tfs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!