Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a TeamCity build as a specific user

Tags:

teamcity

I have a build configuration which deploys my code to a machine. Depending on which machine I am deploying to (e.g. dev/uat/prod), I need to run as a different user.

Rather than hardcoding the username and password in the build files (not really possible as they change regularly for security reasons) I would like to be able to type them in at the point I run the build. I would envisage the "Run Custom Build" in TeamCity would have this option but I can't see anywhere to input that information.

Is there any way to do this (short of remoting into the build agent and changing the user which the build agent runs as)?

Thanks

like image 521
Neil Mosafi Avatar asked Mar 07 '11 17:03

Neil Mosafi


2 Answers

The RunAs plugin combined with TeamCity 7's new Typed Parameters will let you make the password a "typed" parameter plugin.

Then, when it's entered at the Run screen, it will not be visible in the build history.

EDIT: Much later, as covered in the comments: You probably don't want to do this. Consider having separate pools which run as different users, and parameters to specify what builds are supported by what pools.

like image 66
Dan Fitch Avatar answered Oct 05 '22 22:10

Dan Fitch


Neil, you can pass build parameters via Run Custom Build dialog.

There are "System properties" and "Environment variables" sections, where you can add new build parameters or redefine existing ones.

Please read more: http://confluence.jetbrains.net/display/TCD6/Triggering+a+Custom+Build

like image 29
KIR Avatar answered Oct 05 '22 22:10

KIR