简体   繁体   中英

Exclude directory in TeamCity when build has no changes

I want to exclude one catalog from artifacts but only when build has no changes. Is it possible?

My artifacts have 1GB but without that one directory only 25MB. Over half of my builds has no changes like this: teamcity屏幕截图 And this is only one of my projects. I don't have enough space to store it all.

I tried something like this:

Binaries=>Binaries.zip
-:Binaries/DirToExclude/*/.*

but it is not working even without the condition which I'm asking now :(

Add a build step at the end that checks if there are any changes. If there are no changes, then delete the artifact otherwise leave it alone. You could with TC8 set the Execution Policy of the build step to Always, even if build stop command was issued .

You can use the TeamCity REST API to determine if there are any changes left. For example:

curl -u /httpAuth/app/rest/changes?build=id:%teamcity.build.id%

Could return something like this:

<changes count="3">
   <change href="/httpAuth/app/rest/changes/id:217404" id="217404" version="b6b97a0d7789d97df6df908ab582ebb723235f43" webLink="http://teamcity.my-domain.com/viewModification.html?modId=217404&personal=false"/>
   <change href="/httpAuth/app/rest/changes/id:217403" id="217403" version="064ecef5552ec2fb7875d7c26fe54cdf94b67bec" webLink="http://teamcity.my-domain.com/viewModification.html?modId=217403&personal=false"/>
   <change href="/httpAuth/app/rest/changes/id:217402" id="217402" version="9bc3a34c952059bbfc7bebeb79ba5a3c894ef555" webLink="http://teamcity.my-domain.com/viewModification.html?modId=217402&personal=false"/>
</changes>

But you could tie it with curl, grep and awk to get if the number using like:

curl -u %teamcity.auth.userId%:%teamcity.auth.password% %teamcity.serverUrl%/httpAuth/app/rest/changes?build=%teamcity.build.id% | grep "changes" | awk -F"\"" '{print $8}'

Which in the above case would return 3 but if there are no changes it would return 0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM