Closed atifansari13 closed 6 years ago
Hi @atifansari13
are the build definition on the same tfs/vsts server instance/collection?
Could you set the the system.debug variable to true and send me the logs of the build step.
Hi @huserben
Yes. Both my build definitions are on the same vsts server instance. Here are debug logs for the build step.
2018-07-10T12:48:47.8593568Z ##[debug]Evaluating condition for step: 'Trigger a new build of Build2'
2018-07-10T12:48:47.8595186Z ##[debug]Evaluating: succeeded()
2018-07-10T12:48:47.8595565Z ##[debug]Evaluating succeeded:
2018-07-10T12:48:47.8596087Z ##[debug]=> True
2018-07-10T12:48:47.8597040Z ##[debug]Result: True
2018-07-10T12:48:47.8597618Z ##[section]Starting: Trigger a new build of Build2
2018-07-10T12:48:47.8607331Z ==============================================================================
2018-07-10T12:48:47.8607613Z Task : Trigger Build
2018-07-10T12:48:47.8607976Z Description : This tasks allows to trigger a new Build (add it to the queue) as part of a Build Definition. It contains as well some conditions that can be applied, for example if the last build of certain definition was successful or not.
2018-07-10T12:48:47.8608314Z Version : 2.8.6
2018-07-10T12:48:47.8608503Z Author : Benjamin Huser
2018-07-10T12:48:47.8608718Z Help :
2018-07-10T12:48:47.8608974Z ==============================================================================
2018-07-10T12:48:48.8673020Z ##[debug]agent.TempDirectory=C:\VSTS_agents\agent_folder_work_temp
2018-07-10T12:48:48.8714401Z ##[debug]loading inputs and endpoints
2018-07-10T12:48:48.8723484Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-07-10T12:48:48.8745362Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-07-10T12:48:48.8751250Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-07-10T12:48:48.8755110Z ##[debug]loading INPUT_AUTHENTICATIONMETHOD
2018-07-10T12:48:48.8758730Z ##[debug]loading INPUT_BLOCKINPROGRESSBUILDS
2018-07-10T12:48:48.8762176Z ##[debug]loading INPUT_BUILDDEFINITION
2018-07-10T12:48:48.8765560Z ##[debug]loading INPUT_CANCELBUILDSIFANYFAILS
2018-07-10T12:48:48.8768857Z ##[debug]loading INPUT_DEFINITIONISINCURRENTTEAMPROJECT
2018-07-10T12:48:48.8772421Z ##[debug]loading INPUT_DEPENDENTONFAILEDBUILDCONDITION
2018-07-10T12:48:48.8775564Z ##[debug]loading INPUT_DEPENDENTONSUCCESSFULBUILDCONDITION
2018-07-10T12:48:48.8778677Z ##[debug]loading INPUT_DOWNLOADBUILDARTIFACTS
2018-07-10T12:48:48.8781811Z ##[debug]loading INPUT_DROPDIRECTORY
2018-07-10T12:48:48.8784852Z ##[debug]loading INPUT_ENABLEBUILDINQUEUECONDITION
2018-07-10T12:48:48.8786777Z ##[debug]loading INPUT_FAILTASKIFBUILDSNOTSUCCESSFUL
2018-07-10T12:48:48.8790740Z ##[debug]loading INPUT_FAILTASKIFCONDITIONSARENOTFULFILLED
2018-07-10T12:48:48.8793413Z ##[debug]loading INPUT_IGNORESSLCERTIFICATEERRORS
2018-07-10T12:48:48.8796925Z ##[debug]loading INPUT_INCLUDECURRENTBUILDDEFINITION
2018-07-10T12:48:48.8799552Z ##[debug]loading INPUT_QUEUEBUILDFORUSERTHATTRIGGEREDBUILD
2018-07-10T12:48:48.8803253Z ##[debug]loading INPUT_QUEUEID
2018-07-10T12:48:48.8806320Z ##[debug]loading INPUT_STOREINENVIRONMENTVARIABLE
2018-07-10T12:48:48.8809459Z ##[debug]loading INPUT_TFSSERVER
2018-07-10T12:48:48.8811451Z ##[debug]loading INPUT_TREATPARTIALLYSUCCEEDEDBUILDASSUCCESSFUL
2018-07-10T12:48:48.8815362Z ##[debug]loading INPUT_USESAMEBRANCH
2018-07-10T12:48:48.8818383Z ##[debug]loading INPUT_USESAMESOURCEVERSION
2018-07-10T12:48:48.8821496Z ##[debug]loading INPUT_WAITFORQUEUEDBUILDSTOFINISH
2018-07-10T12:48:48.8826519Z ##[debug]loading INPUT_WAITFORQUEUEDBUILDSTOFINISHREFRESHTIME
2018-07-10T12:48:48.8834941Z ##[debug]loaded 26
2018-07-10T12:48:48.8851243Z ##[debug]Agent.ProxyUrl=undefined
2018-07-10T12:48:48.8854484Z ##[debug]Agent.CAInfo=undefined
2018-07-10T12:48:48.8855631Z ##[debug]Agent.ClientCert=undefined
2018-07-10T12:48:48.8856056Z ##[debug]Agent.SkipCertValidation=undefined
2018-07-10T12:48:48.8906089Z ##[debug]definitionIsInCurrentTeamProject=true
2018-07-10T12:48:48.8911623Z ##[debug]tfsServer=https://app.visualstudio.com/
2018-07-10T12:48:48.8917614Z ##[debug]buildDefinition=Build2
2018-07-10T12:48:48.8924070Z ##[debug]ignoreSslCertificateErrors=true
2018-07-10T12:48:48.8927367Z ##[debug]queueBuildForUserThatTriggeredBuild=true
2018-07-10T12:48:48.8929497Z ##[debug]useSameSourceVersion=false
2018-07-10T12:48:48.8932549Z ##[debug]useSameBranch=false
2018-07-10T12:48:48.8934028Z ##[debug]branchToUse=null
2018-07-10T12:48:48.8937679Z ##[debug]waitForQueuedBuildsToFinish=false
2018-07-10T12:48:48.8939737Z ##[debug]waitForQueuedBuildsToFinishRefreshTime=60
2018-07-10T12:48:48.8943593Z ##[debug]failTaskIfBuildsNotSuccessful=true
2018-07-10T12:48:48.8946741Z ##[debug]cancelBuildsIfAnyFails=false
2018-07-10T12:48:48.8959608Z ##[debug]treatPartiallySucceededBuildAsSuccessful=false
2018-07-10T12:48:48.8963422Z ##[debug]downloadBuildArtifacts=false
2018-07-10T12:48:48.8966453Z ##[debug]dropDirectory=C:\VSTS_agents\agent_folder_work
2018-07-10T12:48:48.8969556Z ##[debug]storeInEnvironmentVariable=false
2018-07-10T12:48:48.8970580Z ##[debug]demands=null
2018-07-10T12:48:48.8977984Z ##[debug]queueid=Queue2
2018-07-10T12:48:48.8978997Z ##[debug]buildParameters=null
2018-07-10T12:48:48.8980861Z ##[debug]authenticationMethod=Personal Access Token
2018-07-10T12:48:48.8981501Z ##[debug]username=null
2018-07-10T12:48:48.8982592Z ##[debug]password=null
2018-07-10T12:48:48.8986063Z ##[debug]enableBuildInQueueCondition=false
2018-07-10T12:48:48.8988009Z ##[debug]includeCurrentBuildDefinition=true
2018-07-10T12:48:48.8989109Z ##[debug]blockingBuildsList=null
2018-07-10T12:48:48.8992601Z ##[debug]blockInProgressBuilds=false
2018-07-10T12:48:48.8994470Z ##[debug]dependentOnSuccessfulBuildCondition=false
2018-07-10T12:48:48.8995177Z ##[debug]dependentBuildsList=null
2018-07-10T12:48:48.8998878Z ##[debug]dependentOnFailedBuildCondition=false
2018-07-10T12:48:48.8999948Z ##[debug]dependentFailingBuildsList=null
2018-07-10T12:48:48.9001469Z ##[debug]failTaskIfConditionsAreNotFulfilled=false
2018-07-10T12:48:48.9047846Z Using current Team Project Url
2018-07-10T12:48:48.9056540Z Path to Server: https://app.visualstudio.com/myApp
2018-07-10T12:48:48.9066186Z Using Personal Access Token
2018-07-10T12:48:48.9067681Z Build shall be triggered for same user that triggered current build: user
2018-07-10T12:48:48.9070661Z Build Queue was specified as string: Queue2 - trying to fetch Queue ID for the queue...
2018-07-10T12:48:48.9101370Z ##[debug]Sending Request to following url:
2018-07-10T12:48:48.9102097Z ##[debug]distributedtask/queues
2018-07-10T12:48:48.9310988Z ##[debug]An error happened during the request (Try 1/5)
2018-07-10T12:48:48.9314552Z ##[debug]Error: auth() received invalid user or password
2018-07-10T12:48:48.9345937Z ##[debug]An error happened during the request (Try 2/5)
2018-07-10T12:48:48.9346413Z ##[debug]Error: auth() received invalid user or password
2018-07-10T12:48:48.9359039Z ##[debug]An error happened during the request (Try 3/5)
2018-07-10T12:48:48.9359900Z ##[debug]Error: auth() received invalid user or password
2018-07-10T12:48:48.9369566Z ##[debug]An error happened during the request (Try 4/5)
2018-07-10T12:48:48.9370769Z ##[debug]Error: auth() received invalid user or password
2018-07-10T12:48:48.9385761Z ##[debug]An error happened during the request (Try 5/5)
2018-07-10T12:48:48.9386503Z ##[debug]Error: auth() received invalid user or password
2018-07-10T12:48:48.9386780Z Request was not successful.
2018-07-10T12:48:48.9444907Z { Error: auth() received invalid user or password
2018-07-10T12:48:48.9446044Z at RequestError (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:105:9)
2018-07-10T12:48:48.9446924Z at Request.request [as _callback] (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:61:24)
2018-07-10T12:48:48.9447354Z at self.callback (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:186:22)
2018-07-10T12:48:48.9447754Z at emitOne (events.js:96:13)
2018-07-10T12:48:48.9447964Z at Request.emit (events.js:188:7)
2018-07-10T12:48:48.9449868Z at Auth.basic (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:23:18)
2018-07-10T12:48:48.9450268Z at Auth.onRequest (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:136:23)
2018-07-10T12:48:48.9451276Z at Request.auth (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:1349:14)
2018-07-10T12:48:48.9451650Z at Request.init (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:375:10)
2018-07-10T12:48:48.9452034Z at new Request (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:128:8)
2018-07-10T12:48:48.9452305Z request: undefined,
2018-07-10T12:48:48.9452479Z innerError:
2018-07-10T12:48:48.9452730Z Error: auth() received invalid user or password
2018-07-10T12:48:48.9453032Z at Auth.basic (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:23:32)
2018-07-10T12:48:48.9453759Z at Auth.onRequest (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:136:23)
2018-07-10T12:48:48.9454179Z at Request.auth (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:1349:14)
2018-07-10T12:48:48.9454543Z at Request.init (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:375:10)
2018-07-10T12:48:48.9454932Z at new Request (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:128:8)
2018-07-10T12:48:48.9455295Z at request (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\index.js:53:10)
2018-07-10T12:48:48.9455674Z at Promise (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:52:20)
2018-07-10T12:48:48.9456084Z at create (C:\VSTS_agents\agent_folder_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:51:19)
2018-07-10T12:48:48.9456453Z at Object.
Hi
so when looking at the logs, it seems that you don't specify any Token:
2018-07-10T12:48:48.8980861Z ##[debug]authenticationMethod=Personal Access Token
2018-07-10T12:48:48.8981501Z ##[debug]username=null
2018-07-10T12:48:48.8982592Z ##[debug]password=null
So if you use a PAT to authenticate, then you have to specify the token in the "Password" field. Ideally you define it as a variable that is secret and reference this variable then in the field, as shown here: https://github.com/huserben/TfsExtensions/blob/master/BuildTasks/overview.md#personal-access-token
Can you give this a try?
Hi Ben,
It worked. I thought it would by default use the PAT token. Thanks for your help.
I have a build definition A on VSTS which includes a Trigger Build Task step to trigger build definition B.
Agent A is installed and running with PAT for user A and i am running build definition A on Agent A. When i am configuring the agent A, user A is able to authenticate to VSTS. My PAT token is authorized for all scopes.
I have agent B installed with PAT for user B and i want build definition B to run on Agent B.
Both user A and user B have permission to build definition A and B, agent pool A and B, agent queue A and B.
In my build definition A, the Trigger Build Task step fails saying "Authentication with TFS Server failed. Please check your settings.".
It authenticates fine separately but I am not sure why it is failing when trying to authenticate when triggering another build definition.
Task : Trigger Build Description : This tasks allows to trigger a new Build (add it to the queue) as part of a Build Definition. It contains as well some conditions that can be applied, for example if the last build of certain definition was successful or not. Version : 2.8.6 Author : Benjamin Huser Help :
Using current Team Project Url Path to Server: https://test.visualstudio.com/test Using Personal Access Token Build Queue was specified as string: QueueB - trying to fetch Queue ID for the queue... Request was not successful. { Error: auth() received invalid user or password at RequestError (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:105:9) at Request.request [as _callback] (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:61:24) at self.callback (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:186:22) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at Auth.basic (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:23:18) at Auth.onRequest (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:136:23) at Request.auth (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:1349:14) at Request.init (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:375:10) at new Request (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:128:8) request: undefined, innerError: Error: auth() received invalid user or password at Auth.basic (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:23:32) at Auth.onRequest (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\lib\auth.js:136:23) at Request.auth (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:1349:14) at Request.init (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:375:10) at new Request (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\request.js:128:8) at request (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\request\index.js:53:10) at Promise (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:52:20) at create (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:51:19) at Object. (C:\VSTS_agents\myagent_work_tasks\TriggerBuild_32abcf98-0df6-4711-b2e4-66a405d3c1a6\2.8.6\node_modules\web-request\index.js:38:73)
at next (native) }
Authentication failed - please make sure your settings are correct.
If you use the OAuth Token, make sure you enabled the access to it on the Build Definition.
If you use a Personal Access Token, make sure it did not expire.
If you use Basic Authentication, make sure alternate credentials are enabled on your TFS/VSTS.
Authentication with TFS Server failed. Please check your settings.