How to Create a Custom Access Token in TeamCity

TeamCity provides a UI for creating access tokens with project-specific permissions. However, the UI does not expose every permission available in the TeamCity permission model (based on my experience and setup at least)

I faced this issue when trying to create an access token that could customize build revisions (VCS revisions) in a specific project.

The standard token creation form allows selecting permissions from the Build category, but the Customize build revisions permission is missing from the list, although the user has roles with required rights.

The standard Build permissions include options such as:

  • Change build status
  • Clean build configuration sources
  • Comment build
  • Manually label / merge build sources
  • Mute / unmute problems and tests in project
  • Pause / activate build configuration
  • Pin / unpin build
  • Remove finished build
  • Reorder builds in queue
  • Run build
  • Stop / remove from queue

    As a result, using a token without this permission leads to the following error when attempting to customize a build revision:
HTTP 403 Forbidden
You do not have "Customize build revisions" permission
in project with internal id: project1234

The permission actually exists in TeamCity. The solution is to use the TeamCity REST API to retrieve its ID and explicitly include it when creating a custom access token.

This guide is based on TeamCity 2025.11.8.

Find the TeamCity REST API endpoint

To work around this limitation, we can use the TeamCity REST API.

The endpoint for creating user access tokens is:

POST /app/rest/users/{userLocator}/tokens

For example:

https://TEAMCITY_SERVER/app/rest/users/username:build_user/tokens

You can also inspect the REST API specification available on your TeamCity server:

https://TEAMCITY_SERVER/app/rest/swagger.json

Retrieve all available permissions

Before creating the token, we need to find the internal permission ID.

Use the following request to retrieve permissions assigned to the built-in SYSTEM_ADMIN role:

curl -s \
-H "Authorization: Bearer USER_TOKEN" \
-H "Accept: application/xml" \
"https://TEAMCITY_SERVER/app/rest/roles/id:SYSTEM_ADMIN?fields=permissions(permission(id,name,global))"

The response contains permission IDs, display names, and their scope.

Among the returned permissions, we can find:

<permission id="customize_build_parameters"
name="Customize build parameters"
global="false"/>
<permission id="customize_build_revisions"
name="Customize build revisions"
global="false"/>

This confirms that customize_build_revisions exists in the TeamCity permission model, even though it is missing from the standard Build permissions list in the token creation UI.

The global attribute indicates the permission scope:

  • global="false" — project-level permission.
  • global="true" — global permission.

For our use case, customize_build_revisions is a project-level permission, so we can explicitly associate it with the target project in the token definition.

Create a custom token

Now we can create a token with the required permissions.

Create a file named token.xml:

<token name="myproject-custom-token"
expirationTime="2027-11-27T10:38:59.902+03:00">
<permissionRestrictions>
<permissionRestriction isGlobalScope="false">
<project id="myproject"/>
<permission id="run_build"/>
</permissionRestriction>
<permissionRestriction isGlobalScope="false">
<project id="myproject"/>
<permission id="view_project"/>
</permissionRestriction>
<permissionRestriction isGlobalScope="false">
<project id="myproject"/>
<permission id="view_build_configuration_settings"/>
</permissionRestriction>
<permissionRestriction isGlobalScope="false">
<project id="myproject"/>
<permission id="customize_build_revisions"/>
</permissionRestriction>
</permissionRestrictions>
</token>

The important part is the explicit permission restriction:

<permissionRestriction isGlobalScope="false">
<project id="myproject"/>
<permission id="customize_build_revisions"/>
</permissionRestriction>

Unlike the UI, the XML request allows us to specify the permission ID directly.

Each restriction defines:

  • project — the target TeamCity project ID.
  • permission — the internal permission ID.
  • isGlobalScope="false" — limits the permission to the specified project.

The expiration date uses ISO 8601 format, including the timezone offset.

Send the XML file to TeamCity:

curl -i -X POST \
"https://TEAMCITY_SERVER/app/rest/users/username:build_user/tokens" \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/xml" \
-H "Accept: application/xml" \
--data-binary @token.xml

Replace:

  • TEAMCITY_SERVER with your TeamCity server address.
  • build_user with the target user’s login.
  • USER_TOKEN with an existing token authorized to create tokens for that user.

If the request succeeds, TeamCity creates a new access token with the specified restrictions.

Verify the token permissions

After creating the token, verify that TeamCity saved all restrictions:

curl -s \
-H "Authorization: Bearer USER_TOKEN" \
-H "Accept: application/xml" \
"https://TEAMCITY_SERVER/app/rest/users/username:build_user/tokens?fields=token(name,expirationTime,permissionRestrictions(permissionRestriction(project(id),permission(id),isGlobalScope)))"

Check that the response contains:

<permissionRestriction isGlobalScope="false">
<project id="myproject"/>
<permission id="customize_build_revisions"/>
</permissionRestriction>

Also verify that the token has the expected expiration date and that all permissions are associated with the correct project.

Finally, test the token by attempting to run a build with a custom VCS revision.

How to fix Allure TestOps configuration errors (PostgreSQL, Redis, Spring, RabbitMQ)

Recently, I have migrated our highly available Allure TestOps environment from Kubernetes (AWS) to an RPM-based setup running in on-premise environment. During the migration, I encountered several configuration problems related to task executors, Redis Sentinel with TLS, authentication handling, and RabbitMQ quorum queues.

Before diving into the problems, here is the architecture used in the target environment (on-premise):

  • RabbitMQ cluster (3 nodes, initially using classic queue; later migrated to quorum queues)
  • Redis Sentinel (3 nodes, TLS enabled, internal CA)
  • PostgreSQL (3 nodes, Patroni, dedicated etcd cluster with also 3 nodes)
  • Stateless Allure TestOps (3 “replicas”; 26.1.1 version and then 26.2.1.5)

Issue #1 — Spring Task Executor Initialization Failure

After the migration and startup of the new RPM-based Allure instance, the application failed during initialization with the following error:

org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'exportController'

...

Failed to instantiate
[org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor]:

Factory method 'taskExecutor' threw exception with message: null

The issue was related to changes in task executor logic introduced in the 26.1.1 release. The default thread pool configuration was no longer sufficient for our workload. Although existing executor settings were already present, additional pool sizing parameters became mandatory in practice.

Adding the following parameters resolved the startup issue:

ALLURE_TASKEXECUTOR_MAXPOOLSIZE=200
ALLURE_TASKEXECUTOR_QUEUECAPACITY=1000

Issue #2 — Redis Sentinel TLS Connection Failures

The next issue involved connecting Allure TestOps to Redis Sentinel with TLS enabled:

Caused by: io.lettuce.core.RedisConnectionException:
Cannot connect to Redis Sentinel at redis://1.redisdb.corp.net:26379

java.net.SocketException: Connection reset

The issue was caused by an incorrect Redis SSL property.

Initially configured:

SPRING_REDIS_SSL=true

However, Spring Data Redis implementations expect a different parameter when Redis Sentinel used:

SPRING_DATA_REDIS_SSL_ENABLED=true

After updating the property, the TLS connection to Redis Sentinel started working correctly.

Issue #3 — Redis Sentinel Authentication Problems

After fixing TLS, another Redis-related issue appeared during startup:

NOAUTH HELLO must be called with the client already authenticated.Alternatively, the HELLO <proto> AUTH <user> <pass> option can be usedto authenticate the client and select the RESP protocol version at the same time.

Authentication for Redis Sentinel itself was missing.

Even though the main Redis password was configured, Sentinel authentication requires its own dedicated parameter.

Adding the following parameter resolved the issue:

SPRING_DATA_REDIS_SENTINEL_PASSWORD=pass

And the final Redis configuration looked like this:

# Redis
SPRING_DATA_REDIS_SENTINEL_MASTER=redis
SPRING_DATA_REDIS_SENTINEL_NODES=1.redisdb.corp.net:26379,2.redisdb.corp.net:26379,3.redisdb.corp.net:26379
SPRING_DATA_REDIS_SENTINEL_PASSWORD=pass
SPRING_DATA_REDIS_PASSWORD=pass
SPRING_DATA_REDIS_SSL_ENABLED=true
SPRING_SESSION_STORE_TYPE=REDIS
SPRING_DATA_REDIS_DATABASE=0
ALLURE_REDIS_SESSIONTTL=10d

Issue #4 — RabbitMQ Quorum Queues Not Being Created

The last major issue appeared after upgrading to Allure TestOps 26.2.1.4.

This release introduced support for quorum queues in RabbitMQ.

RabbitMQ cluster was already configured with:

"default_queue_type": "quorum"

However, Allure continued creating classic queues.

Even though RabbitMQ supported quorum queues globally, Allure TestOps still required explicit quorum queue activation through application configuration.

The following parameters must be configured:

ALLURE_UPLOAD_QUORUM_ENABLED=true # Enables quorum queues for all declared queues.
ALLURE_UPLOAD_QUORUM_INITIALGROUPSIZE=3 # Defines the number of replicas for quorum queues.
ALLURE_UPLOAD_QUORUM_DELIVERYLIMIT=5 # Controls the maximum number of message redeliveries.

Bonus Observation: RabbitMQ Messages Stuck in Ready State

During the migration, I also encountered an unusual issue with RabbitMQ 4.3.1 and Allure TestOps 26.2.4 which occurred a few days after migrating to quorum queues. At this point, it’s unclear whether this was caused by a product bug, a RabbitMQ-specific behavior, or a configuration-related issue.

The environment had been operating normally with no signs of instability. However, on one occasion, approximately 4,000 messages accumulated in the Ready state and were not consumed by Allure TestOps. Perfect logs, no connectivity issues, no performance bottlenecks and etc.

The issue was resolved by simply restarting the Allure TestOps application instances, after which message consumption resumed immediately and the queue was processed successfully.

Since the problem occurred only once and has not been reproduced, I could not unable to determine the exact root cause. Teams running large-scale Allure TestOps deployments with RabbitMQ quorum queues may want to monitor queue consumer activity and message backlog metrics closely after upgrades.

I hope these undocumented findings will save someone hours or days during migration or upgrading Allure TestOps.