Is it possible to get the Free Disk Space requirement value from within a build step?
We're attempting to roll some free space alerting to notify the team should a build start approaching is free space requirement.
We have some jobs that start to exceed the originally set free space reqs as time goes on (new assets being added as new features roll out), but haven't been able to find a good solution for notification should this happen, other than finding out when builds start to fail.
What the team is currently working on is a new script to add as a final step in these builds to check the free space requirement against the space used by the current working dir, with notification thresholds. However, we can't seem to be able to pull in that free space requirement value from the Build Feature setting.
Also, if I'm barking up the wrong tree and there's a better solution for this, I'm all ears.
Thanks!
Please sign in to leave a comment.
Hello Anthony!
You may consider using this agent parameter as an agent requirement (https://www.jetbrains.com/help/teamcity/agent-requirements.html):
This is an integer-typed property which will be updated after each build and will show how much free space there is available on the agent side. Unfortunately, I do not think Free Disk Space build feature-specified value is exposed to the build parameters - however, the above approach looks more straightforward.
Speaking of the auto-cleanup, I can also recommend Swabra build feature which will remove any files which were not checked out from the VCS (e.g. build results) - perchance it would be useful for your efforts: https://www.jetbrains.com/help/teamcity/build-files-cleaner-swabra.html#BuildFilesCleaner(Swabra)-ConfiguringSwabraOptions
Please let me know in case of any questions or concerns.
Hey there, the `teamcity.agent.work.dir.freeSpaceMb` value doesn't exactly help us. From what I can tell, that is only the free space on disk for the particular agent that ran the job. Since my team supports multiple projects, while separate build teams support other projects also running on the same TC installation, that value doesn't map to anything particularly meaningful in my situation.
What I was looking for was a way to monitor the actual disk usage for a given build, as in some situations the jobs may need to pull in a number of large assets and artifacts to accomplish it's task. This can vary as new assets are introduced and removed, so a static free space requirement (say setting something like 250GB) may be the right value today, but in a few months that may surge to 300GB for some time before assets are optimized, so we need to know when that 250GB requirement may no longer be the right value, so we can take action and either update the setting or lean on other teams to start optimizing things.
I was able to find a solution, so hopefully this will help someone in the future. The Free Space Requirement value is available through the REST API. Using the below endpoint and the feature id of `jetbrains.agent.free.space`, you can retrieve the feature's settings.