huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
45 stars 22 forks source link

Invalid Web Request results on a default VSTS environment #2

Closed lukx closed 7 years ago

lukx commented 7 years ago

Opening this ticket to keep track of the Problem I mentioned in #1

When using the TriggerBuild Build Step on a VSTS environment and a hosted build agent, we are getting the following error (after working around the issue #1):

2017-03-29T07:33:21.7552395Z Checking if blocking builds are queued
017-03-29T07:33:21.7562407Z Checking Build Definition: Provider Service Build
017-03-29T07:33:22.7663776Z ##[error]System.ArgumentException: Invalid JSON primitive: .
017-03-29T07:33:22.7663776Z    at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()
017-03-29T07:33:22.7663776Z    at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)
017-03-29T07:33:22.7663776Z    at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)
017-03-29T07:33:22.7663776Z    at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
017-03-29T07:33:22.7663776Z    at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, ErrorRecord& error)
017-03-29T07:33:22.7663776Z    at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input)

2017-03-29T07:33:22.7663776Z    at System.Management.Automation.CommandProcessorBase.Complete()

As suggested, we traced back the exact request by adding an Inline PowerShell step requesting the API as it would do with the provided script. The result is the following


2017-03-29T09:28:58.4310426Z ##[command]& 'C:\Users\buildguest\AppData\Local\Temp\tmp12F8.ps1' 
2017-03-29T09:28:59.1230196Z HTTP/1.1 203 Non-Authoritative Information
2017-03-29T09:28:59.1230196Z Pragma: no-cache
2017-03-29T09:28:59.1230196Z X-TFS-ProcessId: 4c0f5eeb-58bb-4848-af6e-648a40b81fae
2017-03-29T09:28:59.1230196Z Strict-Transport-Security: max-age=31536000; includeSubDomains
2017-03-29T09:28:59.1230196Z X-AspNetMvc-Version: 4.0
2017-03-29T09:28:59.1230196Z X-Tfs-Location: /_signin?realm=tss-projects.visualstudio.com&reply_to=https%3A%2F%2Ftss-projects.visualstudio.com%2FmyPitStop%2F_apis%2Fbuild%2Fdefinitions%3Fapi-version%3D2.0%26name%3DMPS%2520Backend%2520Integration%2520Test%2520Suite&redirect=1&context=eyJodCI6MiwiaGlkIjoiNjk3ZDIxYzEtZDQ2My00OGE1LWJkZjQtNjBlOTFhMGFhODkyIiwicXMiOnt9LCJyciI6IiIsInZoIjoiIiwiY3YiOiIiLCJjcyI6IiJ90
2017-03-29T09:28:59.1230196Z Cache-Control: no-cache
2017-03-29T09:28:59.1230196Z Content-Type: text/html; charset=utf-8
2017-03-29T09:28:59.1230196Z Expires: -1
2017-03-29T09:28:59.1230196Z Set-Cookie: VstsSession={"PersistentSessionId":"c2b87a1f-b7c7-4cbf-8db3-1c6e1a9522b4","PendingAuthenticationSessionId":"00000000-0000-0000-0000-000000000000","CurrentAuthenticationSessionId":"00000000-0000-0000-0000-000000000000"}; domain=.visualstudio.com; expires=Mon, 28-Mar-2022 09:28:59 GMT; path=/; secure; HttpOnly,VstsSession={"PersistentSessionId":"c2b87a1f-b7c7-4cbf-8db3-1c6e1a9522b4","PendingAuthenticationSessionId":"ad85d96e-d3a5-4253-8f8a-3af53f40af68","CurrentAuthenticationSessionId":"00000000-0000-0000-0000-000000000000"}; domain=.visualstudio.com; expires=Mon, 28-Mar-2022 09:28:59 GMT; path=/; secure; HttpOnly,__RequestVerificationToken=FeygHaFLXuHH0kj9LoSOJxarMoB_WxDPrpyCZnWM1ue8aWR5FYHqD_6YRCa8HzULTIq_Oa5veekfk0O4HMtEWW-P_OcdXaSTXwRTw-Fm-cPsNmPX2TmjfGBKGq7feBzVF8AT2g2; path=/; secure; HttpOnly,__RequestVerificationToken2efcb2e48-4cd5-4fa6-b0ff-ad2d16e48c8c=FeygHaFLXuHH0kj9LoSOJxarMoB_WxDPrpyCZnWM1ue8aWR5FYHqD_6YRCa8HzULTIq_Oa5veekfk0O4HMtEWW-P_OcdXaSTXwRTw-Fm-cPsNmPX2TmjfGBKGq7feBzVF8AT2g2; path=/; secure; HttpOnly
2017-03-29T09:28:59.1240319Z Server: Microsoft-IIS/10.0
2017-03-29T09:28:59.1240319Z X-AspNet-Version: 4.0.30319
2017-03-29T09:28:59.1240319Z X-Powered-By: ASP.NET
2017-03-29T09:28:59.1240319Z P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
2017-03-29T09:28:59.1240319Z X-Content-Type-Options: nosniff
2017-03-29T09:28:59.1240319Z Date: Wed, 29 Mar 2017 09:28:59 GMT
2017-03-29T09:28:59.1240319Z Content-Length: 14063
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z     
2017-03-29T09:28:59.1240319Z    
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z <html xmlns="http://www.w3.org/1999/xhtml">
2017-03-29T09:28:59.1240319Z <head><title>
2017-03-29T09:28:59.1240319Z    
2017-03-29T09:28:59.1240319Z             Visual Studio Team Services | Sign In
2017-03-29T09:28:59.1240319Z         
2017-03-29T09:28:59.1240319Z </title><meta http-equiv="X-UA-Compatible" content="IE=11;&#32;IE=10;&#32;IE=9;&#32;IE=8" />
2017-03-29T09:28:59.1240319Z     <link rel="SHORTCUT ICON" href="/favicon.ico"/>
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z     <link data-bundlelength="410858" data-bundlename="commoncss" data-highcontrast="/_static/tfs/20170328T062628/_cssbundles/HighContrast/vss-bundle-commoncss-veOANzXZ_e4YlhChg2LT7Vmm7au_itUMgKo2jv585Rbo=" data-includedstyles="jQueryUI-Modified;Core;Splitter;PivotView" href="/_static/tfs/20170328T062628/_cssbundles/Default/vss-bundle-commoncss-vVS3oA7XUzTOWH9geINNy7VHuxARvOKzL2QHkm3tfgjU=" rel="stylesheet" />
2017-03-29T09:28:59.1240319Z <link data-bundlelength="82012" data-bundlename="viewcss" data-highcontrast="/_static/tfs/20170328T062628/_cssbundles/HighContrast/vss-bundle-viewcss-vRoILfie1h3de554uGA7vJ1-e8zFAmNPW6x4hxlvrfhI=" data-includedstyles="VSS.Controls" href="/_static/tfs/20170328T062628/_cssbundles/Default/vss-bundle-viewcss-vW1mipZYLOz9uAXG9PmuxjpP61inU70czxFbSHU9mY0k=" rel="stylesheet" />
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z     <!--UxServices customizations -->
2017-03-29T09:28:59.1240319Z     
2017-03-29T09:28:59.1240319Z     <link href="/_static/tfs/20170328T062628/_content/Authentication.css" type="text/css" rel="stylesheet" />
2017-03-29T09:28:59.1240319Z     
2017-03-29T09:28:59.1240319Z </head>
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1240319Z <body class="platform">
2017-03-29T09:28:59.1240319Z 
2017-03-29T09:28:59.1428392Z     <script type="text/javascript"> var __vssPageContext = {"webContext":{"host":{"id":"a5ca35eb-148e-4ccd-bbb3-d31576d75958","name":"TEAM FOUNDATION","uri":"https://app.vssps.visualstudio.com/","relativeUri":"/","hostType":"deployment","scheme":"https","authority":"app.vssps.visualstudio.com"}},"moduleLoaderConfig":{"baseUrl":"/_static/tfs/20170328T062628/_scripts/TFS/min/","paths":{"VSS/Resources":"en-US","Account/Scripts/Resources":"en-US","Authentication/Scripts/Resources":"en-US","UserManagement/Scripts/Resources":"en-US","Profile/Scripts/Resources":"en-US"},"contributionPaths":{"VSS":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/VSS","pathType":"default"},"VSS/Resources":{"value":"en-US","pathType":"resource"},"q":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/q","pathType":"default"},"knockout":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/knockout","pathType":"default"},"handlebars":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/handlebars","pathType":"default"},"mousetrap":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/mousetrap","pathType":"default"},"react":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/react","pathType":"default"},"react-dom":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/react-dom","pathType":"default"},"jQueryUI":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/jQueryUI","pathType":"default"},"jquery":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/jquery","pathType":"default"},"OfficeFabric":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/OfficeFabric","pathType":"default"},"@uifabric":{"value":"/_static/tfs/20170328T062628/_scripts/TFS/min/@uifabric","pathType":"default"}},"shim":{"jquery":{"deps":[],"exports":"jQuery"}},"waitSeconds":30},"coreReferences":{"stylesheets":[{"url":"/_static/tfs/20170328T062628/_cssbundles/Default/vss-bundle-ext-core-css-vVS3oA7XUzTOWH9geINNy7VHuxARvOKzL2QHkm3tfgjU=","highContrastUrl":null,"isCoreStylesheet":true}],"scripts":[{"identifier":"JQuery","url":"/_static/3rdParty/_scripts/jquery-2.1.1.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},{"identifier":"JQueryXDomain","url":"/_static/3rdParty/_scripts/jquery.xdomainrequest.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},{"identifier":"AMDLoader","url":"/_static/3rdParty/_scripts/requirejs-2.1.14.min.js","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true}],"coreScriptsBundle":{"identifier":"CoreBundle","url":"/_public/_Bundling/Content?bundle=vss-bundle-basejs-vO8_ki-PDDLau6qEZ4C-bHqiRATm1npzQ2B65lnpIYM8=","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true},"extensionCoreReferences":{"identifier":"CoreBundle","url":"/_public/_Bundling/Content?bundle=vss-bundle-ext-core-vDrdu6DGZZ6uaxFP4h3J0Zp36FgXPe_V2xM7w279ZL2o=","fallbackUrl":null,"fallbackCondition":null,"isCoreModule":true}},"webAccessConfiguration":{"isHosted":true,"paths":{"rootPath":"/","staticContentVersion":"20170328T062628","resourcesPath":"/_static/tfs/20170328T062628/_content/","staticRootTfs":"/_static/tfs/20170328T062628/","staticRoot3rdParty":"/_static/3rdParty/"},"api":{"webApiVersion":"1","areaPrefix":"_","controllerPrefix":""},"mailSettings":{"enabled":true,"from":"VisualStudioTeamServices@microsoft.com"}},"microsoftAjaxConfig":{"cultureInfo":{"name":"en-US","numberFormat":{"CurrencyDecimalDigits":2,"CurrencyDecimalSeparator":".","IsReadOnly":true,"CurrencyGroupSizes":[3],"NumberGroupSizes":[3],"PercentGroupSizes":[3],"CurrencyGroupSeparator":",","CurrencySymbol":"$","NaNSymbol":"NaN","CurrencyNegativePattern":0,"NumberNegativePattern":1,"PercentPositivePattern":0,"PercentNegativePattern":0,"NegativeInfinitySymbol":"-∞","NegativeSign":"-","NumberDecimalDigits":2,"NumberDecimalSeparator":".","NumberGroupSeparator":",","CurrencyPositivePattern":0,"PositiveInfinitySymbol":"∞","PositiveSign":"+","PercentDecimalDigits":2,"PercentDecimalSeparator":".","PercentGroupSeparator":",","PercentSymbol":"%","PerMilleSymbol":"%","NativeDigits":["0","1","2","3","4","5","6","7","8","9"],"DigitSubstitution":1},"dateTimeFormat":{"AMDesignator":"AM","Calendar":{"MinSupportedDateTime":"0001-01-01T00:00:00","MaxSupportedDateTime":"9999-12-31T23:59:59.9999999","AlgorithmType":1,"CalendarType":1,"Eras":[1],"TwoDigitYearMax":2029,"IsReadOnly":true},"DateSeparator":"/","FirstDayOfWeek":0,"CalendarWeekRule":0,"FullDateTimePattern":"dddd, MMMM d, yyyy h:mm:ss tt","LongDatePattern":"dddd, MMMM d, yyyy","LongTimePattern":"h:mm:ss tt","MonthDayPattern":"MMMM d","PMDesignator":"PM","RFC1123Pattern":"ddd, dd MMM yyyy HH':'mm':'ss 'GMT'","ShortDatePattern":"M/d/yyyy","ShortTimePattern":"h:mm tt","SortableDateTimePattern":"yyyy'-'MM'-'dd'T'HH':'mm':'ss","TimeSeparator":":","UniversalSortableDateTimePattern":"yyyy'-'MM'-'dd HH':'mm':'ss'Z'","YearMonthPattern":"MMMM yyyy","AbbreviatedDayNames":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"ShortestDayNames":["Su","Mo","Tu","We","Th","Fr","Sa"],"DayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"AbbreviatedMonthNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthNames":["January","February","March","April","May","June","July","August","September","October","November","December",""],"IsReadOnly":true,"NativeCalendarName":"Gregorian Calendar","AbbreviatedMonthGenitiveNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthGenitiveNames":["January","February","March","April","May","June","July","August","September","October","November","December",""]},"numberShortForm":{"QuantitySymbols":["K","M","B"],"NumberGroupSize":1000,"ThousandSymbol":"K"},"eras":null}},"timeZonesConfiguration":{},"featureAvailability":{"featureStates":{"VisualStudio.Services.Contribution.EnableOnPremUnsecureBrowsers":false,"VisualStudio.Service.WebPlatform.ClientErrorReporting":false,"Microsoft.VisualStudio.Services.Gallery.Client.UseCdnAssetUri":false,"VisualStudio.Services.ExtensionManagement.QueryContributionNodes":true}},"appInsightsConfiguration":{"enabled":false,"instrumentationKey":"00000000-0000-0000-0000-000000000000","insightsScriptUrl":null},"diagnostics":{"sessionId":"38112584-d118-4b06-a0ac-133282aa98fe","activityId":"38112584-d118-4b06-a0ac-133282aa98fe","bundlingEnabled":true,"webPlatformVersion":"M114"},"navigation":{"topMostLevel":"deployment","area":"","currentController":"Signin","currentAction":"Index"},"globalization":{"explicitTheme":"","theme":"Default","culture":"en-US","timezoneOffset":0,"timeZoneId":"UTC"},"serviceInstanceId":"951917ac-a960-4999-8464-e3f0aa25b381","hubsContext":{},"serviceLocations":{"locations":{"951917ac-a960-4999-8464-e3f0aa25b381":{"Application":"https://app.vssps.visualstudio.com/","Deployment":"https://app.vssps.visualstudio.com/"}}}};</script><script type="text/javascript"> var __cultureInfo = __vssPageContext.microsoftAjaxConfig.cultureInfo;</script>
2017-03-29T09:28:59.1448423Z <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('startLoadBundleOuter-basejs'); }</script>
2017-03-29T09:28:59.1448423Z <script data-bundlelength="103680" data-bundlename="basejs" src="/_public/_Bundling/Content?bundle=vss-bundle-basejs-vO8_ki-PDDLau6qEZ4C-bHqiRATm1npzQ2B65lnpIYM8=" type="text/javascript"></script>
2017-03-29T09:28:59.1448423Z <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('endLoadBundleOuter-basejs'); }</script>
2017-03-29T09:28:59.1448423Z 
2017-03-29T09:28:59.1448423Z 
2017-03-29T09:28:59.1448423Z <script type="text/javascript"> require.config(__vssPageContext.moduleLoaderConfig);</script>
2017-03-29T09:28:59.1448423Z 
2017-03-29T09:28:59.1448423Z     <input name="__RequestVerificationToken" type="hidden" value="7OjPW8XxsQskuPtHHTyAp1rMNWM4ccti5tABD1W-MOulmpj3kkhcak2Q__vPkeQ-pWpkM8mBhYi_PVAitSJwkqEEpItanzd0vl8BzP5ciV9vR-N4Uibw5_KvpWesuwQgirRpMA2" /><input name="__RequestVerificationToken2" type="hidden" value="__RequestVerificationToken2efcb2e48-4cd5-4fa6-b0ff-ad2d16e48c8c" />
2017-03-29T09:28:59.1448423Z     
2017-03-29T09:28:59.1448423Z     
2017-03-29T09:28:59.1448423Z 
2017-03-29T09:28:59.1448423Z 
2017-03-29T09:28:59.1448423Z     
2017-03-29T09:28:59.1448423Z     
2017-03-29T09:28:59.1448423Z     <div class="account signin main-container hide">
2017-03-29T09:28:59.1448423Z 
2017-03-29T09:28:59.1448423Z 
2017-03-29T09:28:59.1448423Z             <div class="page-content">
2017-03-29T09:28:59.1448423Z                 <div class="header-section">
2017-03-29T09:28:59.1448423Z                     
2017-03-29T09:28:59.1448423Z                     
2017-03-29T09:28:59.1448423Z                 </div>
2017-03-29T09:28:59.1448423Z                 <div class="content-section">
2017-03-29T09:28:59.1448423Z                     
2017-03-29T09:28:59.1448423Z     
2017-03-29T09:28:59.1448423Z             <div class="signin-main-content">
2017-03-29T09:28:59.1448423Z                 <noscript>
2017-03-29T09:28:59.1458416Z                     <span class="error">Microsoft Internet Explorer&#39;s Enhanced Security Configuration is currently enabled on your environment. This enhanced level of security prevents our web integration experiences from displaying or performing correctly. To continue with your operation please disable this configuration or contact your administrator.</span>
2017-03-29T09:28:59.1458416Z                 </noscript>
2017-03-29T09:28:59.1458416Z                 <div class="provider-control">                    
2017-03-29T09:28:59.1458416Z                     <script class="options" defer="defer" type="application/json">{"providerOptions":{"identityProviderDisplayURL":"https://tfsprodch1acs01.accesscontrol.windows.net","identityProviderURL":"https://tfsprodch1acs01.accesscontrol.windows.net/v2/metadata/IdentityProviders.js?protocol=wsfederation\u0026realm=https%3a%2f%2fapp.vssps.visualstudio.com%2f\u0026version=1.0\u0026reply_to=https%3a%2f%2fapp.vssps.visualstudio.com%2f_signedin%3frealm%3dtss-projects.visualstudio.com%26protocol%3dwsfederation%26reply_to%3dhttps%253A%252F%252Ftss-projects.visualstudio.com%252FmyPitStop%252F_apis%252Fbuild%252Fdefinitions%253Fapi-version%253D2.0%2526name%253DMPS%252520Backend%252520Integration%252520Test%252520Suite","staySignedIn":true,"staySignedInCookiePath":"/","force":false,"autoSelect":true,"orgIdAuthUrl":"https://login.microsoftonline.com/common/oauth2/authorize?client_id=499b84ac-1321-427f-aa17-267ca6975798\u0026site_id=501454\u0026response_mode=form_post\u0026response_type=code+id_token\u0026redirect_uri=https%3A%2F%2Fapp.vssps.visualstudio.com%2F_signedin\u0026nonce=ad85d96e-d3a5-4253-8f8a-3af53f40af68\u0026state=realm%3Dtss-projects.visualstudio.com%26reply_to%3Dhttps%253A%252F%252Ftss-projects.visualstudio.com%252FmyPitStop%252F_apis%252Fbuild%252Fdefinitions%253Fapi-version%253D2.0%2526name%253DMPS%252520Backend%252520Integration%252520Test%252520Suite%26ht%3D2%26nonce%3Dad85d96e-d3a5-4253-8f8a-3af53f40af68\u0026resource=https%3A%2F%2Fmanagement.core.windows.net%2F\u0026cid=ad85d96e-d3a5-4253-8f8a-3af53f40af68\u0026wsucxt=1\u0026domain_hint=live.com","user":null,"signInContext":"eyJodCI6MiwiaGlkIjoiNjk3ZDIxYzEtZDQ2My00OGE1LWJkZjQtNjBlOTFhMGFhODkyIiwicXMiOnsicmVhbG0iOiJ0c3MtcHJvamVjdHMudmlzdWFsc3R1ZGlvLmNvbSIsInJlcGx5X3RvIjoiaHR0cHM6Ly90c3MtcHJvamVjdHMudmlzdWFsc3R1ZGlvLmNvbS9teVBpdFN0b3AvX2FwaXMvYnVpbGQvZGVmaW5pdGlvbnM_YXBpLXZlcnNpb249Mi4wJm5hbWU9TVBTJTIwQmFja2VuZCUyMEludGVncmF0aW9uJTIwVGVzdCUyMFN1aXRlIiwiaHQiOiIyIiwibm9uY2UiOiJhZDg1ZDk2ZS1kM2E1LTQyNTMtOGY4YS0zYWY1M2Y0MGFmNjgifSwicnIiOiIiLCJ2aCI6IiIsImN2IjoiIiwiY3MiOiIifQ2"}}</script>
2017-03-29T09:28:59.1458416Z                 </div>
2017-03-29T09:28:59.1458416Z             </div>
2017-03-29T09:28:59.1458416Z 
2017-03-29T09:28:59.1458416Z 
2017-03-29T09:28:59.1458416Z                 </div>
2017-03-29T09:28:59.1458416Z                  
2017-03-29T09:28:59.1458416Z                      <div>
2017-03-29T09:28:59.1458416Z                           
2017-03-29T09:28:59.1458416Z                      </div>
2017-03-29T09:28:59.1458416Z                  
2017-03-29T09:28:59.1458416Z             </div>
2017-03-29T09:28:59.1458416Z             
2017-03-29T09:28:59.1458416Z     
2017-03-29T09:28:59.1458416Z     </div>
2017-03-29T09:28:59.1458416Z 
2017-03-29T09:28:59.1458416Z 
2017-03-29T09:28:59.1458416Z     
2017-03-29T09:28:59.1458416Z     
2017-03-29T09:28:59.1458416Z 
2017-03-29T09:28:59.1458416Z     <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('startLoadBundleOuter-common'); }</script>
2017-03-29T09:28:59.1458416Z <script data-bundlelength="134205" data-bundlename="common" data-includedscripts="VSS/Bundling" src="/_public/_Bundling/Content?bundle=vss-bundle-common-vB4381bOD3uDgRXsPI_0V3cK45BSN-5bUYD3PagSZZMM=" type="text/javascript"></script>
2017-03-29T09:28:59.1458416Z <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('endLoadBundleOuter-common'); }</script>
2017-03-29T09:28:59.1458416Z <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('startLoadBundleOuter-view'); }</script>
2017-03-29T09:28:59.1458416Z <script data-bundlelength="181873" data-bundlename="view" data-includedscripts="Authentication/Scripts/SPS.Authentication.Controls;Authentication/Scripts/SPS.Authentication" src="/_public/_Bundling/Content?bundle=vss-bundle-view-vDVHtzxQ2zGm2sgRV7e0iCYdzb-53t2o-DTRDbjBBD9o=" type="text/javascript"></script>
2017-03-29T09:28:59.1468428Z <script type="text/javascript">if (window.performance && window.performance.mark) { window.performance.mark('endLoadBundleOuter-view'); }</script>
2017-03-29T09:28:59.1468428Z 
2017-03-29T09:28:59.1468428Z <script type="text/javascript"> if (window.performance && window.performance.mark) { window.performance.mark('requireStart'); }
2017-03-29T09:28:59.1468428Z require(["Authentication/Scripts/SPS.Authentication.Controls","Authentication/Scripts/SPS.Authentication"], function(){  if (window.performance && window.performance.mark) { window.performance.mark('requireEnd'); } window.requiredModulesLoaded=true;  });
2017-03-29T09:28:59.1468428Z </script>
2017-03-29T09:28:59.1468428Z 
2017-03-29T09:28:59.1468428Z </body>
2017-03-29T09:28:59.1468428Z </html>
2017-03-29T09:28:59.1468428Z 

We'll invest some more time into looking into the reasons this page is displayed to our API client.

lukx commented 7 years ago

Just so you don't have too scroll through the HTML Page, the error hidden in there is

Microsoft Internet Explorer's Enhanced Security Configuration is currently enabled on your environment. This enhanced level of security prevents our web integration experiences from displaying or performing correctly. To continue with your operation please disable this configuration or contact your administrator.

I am opening a Build-Agent Ticket at VSTS [Edit] Done at https://github.com/Microsoft/vsts-agent/issues/885

huserben commented 7 years ago

Hi

do you specify the username and password for for the user that accesses the TFS API under Advanced Configuration? If you use a hosted build agent you need to specify a username/password combination that has the required rights on the TFS.

I tried quickly with a git Repo hosted on VSTS and it worked when specifiying username/password, by default this option is not enabled and i had the similar issue:

2017-03-29T18:40:49.9708860Z Preparing task execution handler. 2017-03-29T18:40:54.6575987Z Executing the powershell script: C:\a\_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\1.3.16\triggerbuild.ps1 2017-03-29T18:40:55.2524957Z Using Current Team Project URL 2017-03-29T18:40:55.2915096Z Path to Server: https://benjsawesometfstest.visualstudio.com//GitTest 2017-03-29T18:40:55.2915096Z Using Default Credentials 2017-03-29T18:40:55.2915096Z Build In Queue Condition is not enabled 2017-03-29T18:40:55.2924909Z Dependant Build Condition is not enabled 2017-03-29T18:40:55.5950195Z ##[error]System.ArgumentException: Invalid JSON primitive: . 2017-03-29T18:40:55.5950195Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() 2017-03-29T18:40:55.5950195Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) 2017-03-29T18:40:55.5950195Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) 2017-03-29T18:40:55.5950195Z at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) 2017-03-29T18:40:55.5950195Z at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, ErrorRecord& error) 2017-03-29T18:40:55.5950195Z at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input) 2017-03-29T18:40:55.5950195Z at System.Management.Automation.CommandProcessorBase.Complete()

nobitagamer commented 7 years ago

Even set the username and password, i'm still have the above error.

huserben commented 7 years ago

You are sure the user has the rights to access the TFS API? Could you try to manually send the request with the credentials and check the return value? I think as well that you would need to allow "alternate authentication credentials" via your Profile --> Security -> Alternate Authentication Credentials and then use this username/password combination to trigger the build.

Otherwise could you setup a demo VSTS project that I could access and in which the error is reproduced?

huserben commented 7 years ago

Hi @lukx and @nobitagamer do you have any updates? I'd like to help but it's hard as I cannot really reproduce the issue, except if there is a problem with the Authentication which causes the TFS API to reroute to a login page, and in that case it is more a setting issue than a problem with the scripts.

I would really appreciate the return value of the webrequest. With Postman you can send a request to this url: https://**yourtfs**.visualstudio.com/DefaultCollection/**yourproject/team**/_apis/build/builds?api-version=2.0 If you are not using VSTS just adapt accordingly and set the correct collection.

Thanks for your collaboration

nobitagamer commented 7 years ago

Yes, with Postman i can send request successfully, now workaround for me is use a Powershell step to invoke web request to that API but that's not my expected solution since your extension provide really cool feature that i need.

Below is my script in case you need: ` $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build/builds?api-version=2.0" $body = "{ 'definition' : { 'id' : $env:IOSBUILD_DEFINITIONID }, 'sourceBranch' : '$env:BUILD_SOURCEBRANCH' }" $type = "application/json"

$headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }

Write-Host "URL: $url" $definition = Invoke-RestMethod -Uri $url -Body $body -ContentType $type -Method Post -Headers $headers Write-Host "Definition = $($definition | ConvertTo-Json -Depth 100)" `

nobitagamer commented 7 years ago

P/S: I've dig into your source and i think may be problem because you're using Basic Authentication instead of Bearer header like me (VSTS maybe updated and force that or whatever i'm not sure).

huserben commented 7 years ago

Hi

oh ok, now it makes sense. I think I never tested that so far, sorry. I will have a look as soon as possible.

huserben commented 7 years ago

Hi the lates check in should have solved your issue. Version 1.4.0 should now support the usages of Personal Access Tokens. I updated the version in the Marketplace, next time you run the build it should automatically take this one.

Please test it and let me know if it worked :-)

Really appreciated your help in solving this issue, thank you 👍

nobitagamer commented 7 years ago

With 'Default' checked: 2017-04-04T02:34:07.0910307Z ##[error]System.ArgumentException: Invalid JSON primitive: . 2017-04-04T02:34:07.0910307Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() 2017-04-04T02:34:07.0910307Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) 2017-04-04T02:34:07.0910307Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) 2017-04-04T02:34:07.0910307Z at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) 2017-04-04T02:34:07.0910307Z at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, ErrorRecord& error) 2017-04-04T02:34:07.0910307Z at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input) 2017-04-04T02:34:07.0910307Z at System.Management.Automation.CommandProcessorBase.Complete() 2017-04-04T02:34:07.0920327Z ##[error]System.Management.Automation.RuntimeException: Cannot index into a null array. 2017-04-04T02:34:07.0920327Z at CallSite.Target(Closure , CallSite , Object , Int32 ) 2017-04-04T02:34:07.0920327Z at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 2017-04-04T02:34:07.0920327Z at System.Management.Automation.Interpreter.DynamicInstruction3.Run(InterpretedFrame frame) 2017-04-04T02:34:07.0920327Z at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2017-04-04T02:34:07.6168472Z ##[error]System.ArgumentException: Invalid JSON primitive: . 2017-04-04T02:34:07.6168472Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() 2017-04-04T02:34:07.6168472Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) 2017-04-04T02:34:07.6168472Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) 2017-04-04T02:34:07.6168472Z at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) 2017-04-04T02:34:07.6168472Z at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, ErrorRecord& error) 2017-04-04T02:34:07.6168472Z at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input) 2017-04-04T02:34:07.6168472Z at System.Management.Automation.CommandProcessorBase.Complete() 2017-04-04T02:34:07.6188738Z Checking Build Definition: 2017-04-04T02:34:08.1410598Z ##[error]System.ArgumentException: Invalid JSON primitive: . 2017-04-04T02:34:08.1410598Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() 2017-04-04T02:34:08.1410598Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) 2017-04-04T02:34:08.1410598Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) 2017-04-04T02:34:08.1410598Z at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) 2017-04-04T02:34:08.1410598Z at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, ErrorRecord& error) 2017-04-04T02:34:08.1410598Z at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input) 2017-04-04T02:34:08.1410598Z at System.Management.Automation.CommandProcessorBase.Complete() 2017-04-04T02:34:08.1410598Z ##[error]System.Management.Automation.RuntimeException: Cannot index into a null array. 2017-04-04T02:34:08.1410598Z at CallSite.Target(Closure , CallSite , Object , Int32 ) 2017-04-04T02:34:08.1410598Z at System.Management.Automation.Interpreter.DynamicInstruction3.Run(InterpretedFrame frame) 2017-04-04T02:34:08.1410598Z at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2017-04-04T02:34:08.6607702Z ##[error]System.ArgumentException: Invalid JSON primitive: . 2017-04-04T02:34:08.6607702Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() 2017-04-04T02:34:08.6607702Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) 2017-04-04T02:34:08.6607702Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) 2017-04-04T02:34:08.6607702Z at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) 2017-04-04T02:34:08.6607702Z at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, ErrorRecord& error) 2017-04-04T02:34:08.6607702Z at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input) 2017-04-04T02:34:08.6607702Z at System.Management.Automation.CommandProcessorBase.Complete() 2017-04-04T02:34:08.6607702Z None of the blocking builds is queued - proceeding 2017-04-04T02:34:09.1822849Z ##[error]System.ArgumentException: Invalid JSON primitive: . 2017-04-04T02:34:09.1822849Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() 2017-04-04T02:34:09.1822849Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) 2017-04-04T02:34:09.1822849Z at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) 2017-04-04T02:34:09.1822849Z at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) 2017-04-04T02:34:09.1822849Z at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input, ErrorRecord& error) 2017-04-04T02:34:09.1822849Z at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input) 2017-04-04T02:34:09.1822849Z at System.Management.Automation.CommandProcessorBase.Complete() 2017-04-04T02:34:09.1822849Z ##[error]System.Management.Automation.RuntimeException: Cannot index into a null array. 2017-04-04T02:34:09.1822849Z at CallSite.Target(Closure , CallSite , Object , Int32 ) 2017-04-04T02:34:09.1822849Z at System.Management.Automation.Interpreter.DynamicInstruction3.Run(InterpretedFrame frame) 2017-04-04T02:34:09.1822849Z at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)`

nobitagamer commented 7 years ago

With 'Default' unchecked and PAT selected: Checking if blocking builds are queued Checking Build Definition: pudge-war vNext-CI Checking Build Definition: System.Net.WebException: The remote server returned an error: (400) Bad Request. at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() System.Management.Automation.RuntimeException: Cannot index into a null array. at CallSite.Target(Closure , CallSite , Object , Int32 ) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at System.Management.Automation.Interpreter.DynamicInstruction3.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) None of the blocking builds is queued - proceeding`

PS: I think the above error because i'm leave the textbox empty like below: image

After fill in some text the task worked correctly but not as my expected: Check the use 'Default', turn on 'Allow Scripts to Access OAuth Token' and Done!

nobitagamer commented 7 years ago

The correct fix maybe: include $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } in Invoke-WebRequest instead of: -UseDefaultCredentials in your code (the $env:SYSTEM_ACCESSTOKEN can be access only when turn on 'Allow Scripts to Access OAuth Token')

huserben commented 7 years ago

Hi sorry again, when I looked at it yesterday, I thought you would need to use Personal Access Tokens and not OAuth, my bad. I will try to have a look at it tonigt (CET) and will let you know when I'm done. Do you know if there is the need to ever specifiy the token yourself instead of using "System.AccessToken"? From what I saw it is not available in the Release Management as a variable. If so I would make it as well configurable and leave the option to either use default credentials, default access token, or using Personal Access Token, OAuth Token or Basic Auth.

Thanks again for your support

nobitagamer commented 7 years ago

The 'System.AccessToken' is generic access token that's enough for read-only tasks and queue build action so i'll never generate a PAT for some tasks except in case i need to push code back too my repository that requires a write permission. With your current Default checkbox, use System.AccessToken maybe the best solution.

nobitagamer commented 7 years ago

Aw, now i'm facing with error: None of the blocking builds is queued - proceeding Queue new Build for definition pudge-war vNext-CI System.Net.WebException: The remote server returned an error: (409) Conflict. at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() System.Net.WebException: The remote server returned an error: (400) Bad Request. at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() Queued new Build for Definition pudge-war vNext-CI (Unity3D on macOS) PowerShell script completed with 2 errors. But it still success until tonight.

huserben commented 7 years ago

Hi I just uploaded a new version that supports the OAuth Access Token. Please try it and come back to me

nobitagamer commented 7 years ago

Cool, now it worked like a charm. That's perfect, thank you!

huserben commented 7 years ago

Ok, i'll close the issue then.

Thanks for your support, helped me a lot in figuring out what was actually wrong 👍