Skip to content

How to use

Nikolay Pianikov edited this page Dec 7, 2017 · 88 revisions

The plugin provides the Run As build feature and you can add it to your build configuration specifying the username and password.

For example

For Windows the following username formats are acceptable:〈username〉or〈username@domain〉or〈domain\username〉and it is possible to specify the Windows Integrity Level, the logging level, and additional arguments.

If the credentials are invalid, the build fails with “Authentication failure”.

Alternatively, to make sure the teamcity-runas plugin is configured properly, you can get the user whose account was used to run the build by checking the environment variables: USERNAME (for Windows) / USER, LOGNAME (for Linux).

For example, you can add Command line build step with: whoami. This will print the user whose account was used to run the build into the log.

Accessing Files created by ‘Run As’ User

⚠️ It is important to note that when running a build under a specified user account, all processes run in the environment specific for this user.

It means that all files created during the build (e.g. compiled classes, object files, executables, dlls, Gradle/Maven cache files, TeamCity artifacts, some test statistics and so on) will have the teamcity-runas user as the file owner.

The TeamCity agent must have the full control over the files created in the build checkout directory and ideally, over files in other locations, e.g. m2 or .gradle directories as well. Depending on the way you configured the agent, the access level will differ and granting additional permissions may be required.

  • For Windows, the account with administrative permissions used to run the TeamCity build agent will have sufficient rights to manage the files.

  • For Linux, if the TeamCity agent is not running under ROOT, it may encounter problems accessing artifacts in the build checkout directory. In this case the necessary permissions can be granted by running the following command:

    chmod -R a+rwX %teamcity.build.checkoutDir%
    

    as the last step of the build executed under the ‘Run As’ user.