Add label to TFS SourceControl during vNext build

0

I am useing TFS 2017 on-prem.

I received a request to add label to specific path if the build success.

I added "Command Line" Task and run the command:

TF.exe vc label "New-Label" $/My-System/Version/Project 

I got an error:

[error]TF30063: You are not authorized to access

When this command running from console it work even from the build machine, but failed when it executed during build process.

Also try to run tf with loginType & login parameters, batch file or from PowerShell Task without success

** The option "Label Source" in "Get Sources" task is not relevant becuse I want to add the label to just one path from the list of paths in "Workspace mappings"

CodeOnce

Posted 2019-04-17T06:43:44.963

Reputation: 3

Answers

0

You can try to use OAuth for tfs.exe. OAuth is stored in the System.AccessToken variable. Example:

TF.exe vc label "MyLablel" MyFolder /loginType:OAuth /login:.,$(System.AccessToken) 

Additionally you have to enable the access to this variable (I can not check that because I do not have tfs 2017).

Helpful links:

  1. Allow scripts to access the OAuth token
  2. System.AccessToken

Shamrai Aleksander

Posted 2019-04-17T06:43:44.963

Reputation: 141

Thanks for the quick response. – CodeOnce – 2019-04-18T08:26:52.837