Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

TeamCity RunAs plugin

branch: master

fix URL

latest commit cd7ad61126
Pavel Sher authored
Octocat-spinner-32 .idea project files fixes September 21, 2011
Octocat-spinner-32 runas-agent fix plugin to be compatible with 6.5.3 and above September 21, 2011
Octocat-spinner-32 .gitignore first commit July 13, 2011
Octocat-spinner-32 LICENSE.txt first commit July 13, 2011
Octocat-spinner-32 README fix URL November 11, 2011
Octocat-spinner-32 runas.iml project files fixes September 21, 2011
Octocat-spinner-32 teamcity-plugin.xml version == snapshot September 21, 2011
README
This is a RunAs plugin for JetBrains TeamCity: http://www.jetbrains.com/teamcity/

With help of this plugin you can run builds under different user accounts or perform some additional actions before or after build process.

Download
===========

The last build of RunAs plugin can be downloaded from:
http://teamcity.jetbrains.com/guestAuth/repository/download/bt332/lastSuccessful/runas.zip

How To Build
==================

1) Download and install TeamCity version 6.5.3 or later (http://www.jetbrains.com/teamcity/download/index.html)
2) Download and install IntelliJ IDEA Community or Ultimate Edition (http://www.jetbrains.com/idea/download/index.html)
3) Open project in IntelliJ IDEA
4) Set TEAMCITY_DISTR path variable to directory where TeamCity is installed
5) Choose Menu Build -> Build Artifacts
6) Select runas-plugin artifact from the menu
7) runas.zip file must be created in the project root


How To Install
==================

Copy runas.zip to .BuildServer/plugins and restart TeamCity server. This will cause automatic agents upgrade.


How To Use
============

* Open <agent inst dir>/conf/buildAgent.properties file for editing.
* Specify there additional property: teamcity.build.runAs.command
* This property has the following format:
<path to executable> <arg1> <arg2> ... <argN> {start_build_script}
where path to executable - is a path to some executable which will start the build process, the path must be quoted if it contains spaces
arg1, argN - arguments for this executable
{start_build_script} - path to a script (.cmd on Windows or .sh on Unix) generated by this plugin which contains command line to start build process

Note that if you want to run build under different user account build agent itself must be started under the privileged user.
Build agent needs to have full access to checkout directories, spawned processes (to be able to kill them), temporary files created by the build.
On Linux this means the agent must have root privileges.

Examples:

* Run as different user account on Windows (psexec)

teamcity.build.runAs.command="C:\\Program Files\\SysInternals\\psexec.exe" -u %runas.username% -p %runas.password% {start_build_script}

Note that in this case %runas.username% and %runas.password% will be substituted with real values provided in the build. For example, you can define values for these parameters in a TeamCity project.

* Run as different user account on Linux (sudo)

teamcity.build.runAs.command=<path to runas.sh> %runas.username% %runas.password% {start_build_script} %teamcity.build.checkoutDir% %system.teamcity.build.tempDir%

runas.sh:
#!/bin/bash
user=$1
pwd=$2
script=$3
checkoutdir=$4
tempdir=$5

chown -R $user $checkoutdir
chown -R $user $tempdir
echo $pwd | sudo -S -u $user $script


License
==========

Apache License 2.0


Author
========

Pavel Sher (pavel.sher@gmail.com)

Something went wrong with that request. Please try again.