How to change build step gradle tasks based on requestor type.


We have a requirement to change the build step - gradle tasks based on requestor type.

Our default gralde tasks are 'clean upload' this option should be applicable for only few developer and other should have only 'build' option to the same build configuration.

We could not able to fix the solution through open API, can someone help us.


Comment actions Permalink


We don't recommend to mix these tasks. Better solution would be to store them as two separete build configurations.
Then each configuration has its own independent history, statistics, and status.

Comment actions Permalink

Hi Michael,

Thanks for the response.

In my project we have approximately 400 build configurations. So it will become difficult to make two different configurations. Can you please suggest me the alternate solution.


Comment actions Permalink


Sorry for the delay in responce.

TeamCity does not support such a level of details in persmissions.

The best solution so far will allow privileged developers to run "clean upload" task manually.

If that suits you, here what needs to be done:

1. Create 2 user roles for your projects. The easiest way is to edit roles-config.xml in <TeamCity data directory>/config (see this doc) One groupd must be copy of default PROJECT_DEVELOPER role, excluding CUSTOMIZE_BUILD_PARAMETERS permission. It will represent "regular developers". Second group, "privileged developers" must include "regular developers" plus CUSTOMIZE_BUILD_PARAMETERS permission. Assing this role to required user groups.

2. In your build configurations create new build parameter, name it "gradle.step.tasks" with value "build".

3. In Gradle build steps replace tasks with reference to parameter %gradle.step.tasks%

From this moment, all automatically triggered builds will run with "build" gradle step.

If "privileged developer" needs to do an upload, he open web UI and use "Run Custom Build Dialog". In it, he will be able to override "gradle.step.tasks" with required value (e.g., "clean upload")


Please sign in to leave a comment.