Last week I was asked if there is another way to upgrade UrbanCode Agents then selecting them on the GUI and running the upgrade action.
There are several ways to upgrade the agents automatically. In this blog, I will show you how you can achieve that with Python.
But first, we have to prepare a service account on UrbanCode Deploy so that we won’t use real user accounts.
For that, we create a new role, the UC Agent Upgrader role.
This new Role will only have a very limited permission set. Provide only access to Agents (View Agents) and a few edit rights on them.
To access (read/write) some agent-related data (f.e. tags) it needs “Edit Basic Settings” and “Manage Version Imports”. Also, last but not least “Upgrade Agents” rights.
Create a new User (Service Account) and assign a new role to it. Assign this User to the appropriate teams (f.e. create a service account team).
For security reasons, we will use token access instead of user id and password. So let’s create a new token for UC Agent Upgrader.
After creation save the newly created token information as it will not be shown again. If you have not done it delete this token and create a new one.
My python script reads all agents from the given UrbanCode Deploy server and iterates through the list looking for a tag named “upgrade”.
If this tag is attached to an agent, it will trigger the upgrade procedure and then will remove the tag.