Adilson de Almeida Jr
Adilson de Almeida Jr

Reputation: 2755

Visual Studio Build Agent scripted setup

I´m trying to automate VSTS Build Agent Setup (https://www.visualstudio.com/en-us/docs/build/actions/agents/v2-windows).

However there's an interactive step in the process. It´s a cmd script file which requires user's input. I tried to generate a TXT file with the settings, and run the script reading the input from that file:

.\config < settings.txt

But it didn´t work. I got that message:

Enter server URL > Enter authentication type (press enter for PAT) > Enter perso
nal access token > Cannot read keys when either application does not have a cons
ole or when console input has been redirected. Try Console.Read.

Is it possible to set up a build agent by script? Is there any way to "redirect" the console input in a such way that this config.cmd works perfectly?

Upvotes: 4

Views: 2159

Answers (1)

Thom Schumacher
Thom Schumacher

Reputation: 1583

Did you try passing --help to the Config.cmd

There are a number of examples below is a snippet of the examples:

Unattended configure and unconfigure examples:

Remember to check return code when using unattended configuration

Unattend configuration for VSTS with PAT authentication

Win  : .\config.cmd --unattended --url https://myaccount.visualstudio.com --auth PAT --token <token> --pool default --agent myagent

Unix : ./config.sh --unattended --acceptteeeula --url https://myaccount.visualstudio.com --auth PAT --token <token> --pool default --agent myagent

Unattended configuration for on-premise TFS with integrated (Windows) and (Linux/OSX) negotiate authentication

Win  : .\config.cmd --unattended --url http://mylocaltfsserver:8080/tfs --auth Integrated --pool default --agent myagent

Unix : ./config.sh --unattended --acceptteeeula --url http://mylocaltfsserver:8080/tfs --auth Negotiate --username DOMAIN\USER_NAME --password MyPassword --pool default --agent myagent

Upvotes: 6

Related Questions