Today we needed a way to determine build runner usage across all TeamCity projects. We were using a custom build runner – Node.js NPM – in several projects in TeamCity, but we didn’t know exactly which projects. And we wanted to upgrade the version of Node.js on our build server.
The Node.js NPM build runner allows you to integrate Node.js into your build steps. But, unless you’ve configured the related build steps to use a specific Node version, it will use whichever version that is currently installed on the build agent. So if we didn’t pay attention, upgrading Node.js had the potential to break some of our existing build configurations.
Searching the TeamCity UI
Initially, I thought the TeamCity UI might reveal which projects were using this build runner. In the Administration section, I found the Usage Statistics node (see Figure 1.) While this told me how many build configurations (22) were using this build runner, I couldn’t find information on which projects those were. Next I tried the Plugins List node, but that page had little more than name, rank, and serial number. Still thwarted, I headed for the interwebs.
Searching the Web for an Answer
I spent quite a bit of time googling on Bing (h/t to Hanselman) to see if I could find how to do this. Not only was my old standby StackOverflow silent on this issue, but also the TeamCity documentation itself wasn’t of much use. I was feeling rather stuck. Finally, I ended up searching on the TeamCity issue tracker. One particular request gave me just enough information to figure out the answer.
Narrowing in on a Solution
Next I remoted to our build server. Opening a command prompt, I issued the following command:
Once I had that answer the rest was relatively simple.
Opening Windows Explorer in the folder revealed in the previous step, I moved into the subfolder “.\config\projects”, and there I could see a folder for each of our build projects. I knew the name of at least one project that was using the step in question, so I moved inside that project’s folder, and then into the “BuildTypes” sub-folder. So my path looked like this (for example):
Inside that folder, I could see an .xml file for each of that project’s build configurations. I opened one of these and looked inside. Here is part of what I saw:
<build-runners> <runner id="RUNNER_409" name="NPM Installs - Web" type="jonnyzzz.npm"> <parameters> <param name="npm_commands" value="install" />
Finding Build Runner Usage
So now I knew that the identifier”jonnyzzz.npm” was associated with the build runner of interest. The next step was to grep through every project’s configuration file. In my case, I was using NotePad++. The setup for my search looked like Figure 2.
As soon as I ran that, I got a hit on every build project and build configuration that used that build runner.
So there you have it – how to find build runner usage in TeamCity. Now you can too.