Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining artifacts in TeamCity

Tags:

teamcity

I've looked through a fair number of these discussions with no success so far.

Our build process (on TeamCity 6.5.5) produces two folders, A and B.

We are currently zipping folder B for deployment (artifact path .\B => B-%build.number%.zip). However, it's been decided that folder A should be included as an archive in the zip of B. That is, following the build, B-2.0.0.zip should look like:

B-2.0.0.zip
    file 1
    ...
    file n
    A.zip
        file a1
        ...
        file an

To accomplish this, I've added the artifact path .\A => .\B\A.zip before the existing zip rule for B, so our artifact paths look like:

.\A => .\B\A.zip
.\B => .\B-%build.number%.zip

However, while A.zip is produced (I can see it in folder B following the build), it is not added to the archive B.zip. I looked at the build output, and the artifacts were created in the order expected.

Frankly, I'm stumped. Any insight would be well and truly appreciated. I could potentially modify the build script to accomplish this, but I'd rather not if at all possible.

Thanks in advance.

Edit (2/24/12): On further research, it seemed like I was running into an issue with A.zip being created as a temporary file and moved into place after all artifacts were created.

So, I tried reordering my artifact paths as follows:

.\B => .\B-%build.number%.zip
.\A => .\B-%build.number%.zip\A.zip

I thought this would insert A.zip into B.zip. Instead of a nested archive, it creates a folder named A.zip. Am I just looking at a limitation of TeamCity not being able to nest archives?

like image 410
TimW Avatar asked Feb 23 '12 17:02

TimW


Video Answer


2 Answers

At least with version 9, it is now possible to add multiple files to the same zip file by doing something like this in the "artifacts paths" field:

.\A => myArchive.zip
.\B => myArchive.zip

Not sure though, if subfolders / sub-archives can be created on the fly ...

like image 99
Markus Avatar answered Jan 04 '23 06:01

Markus


One option might be to use a Teamcity Service mesage to create the first archive before the build is finished.

##teamcity[publishArtifacts '.\A => .\B\A.Zip']

Then have team city give back the build artifact in the artifact packaging step in the build configuration:

Something like:

%env.TEAMCITY_DATA_PATH%\system\artifacts\%env.TEAMCITY_PROJECT_NAME%\%env.TEAMCITY_BUILDCONF_NAME%\%env.BUILD_NUMBER%\B\A.zip => .\B-%build.number%.zip
.\B => .\B-%build.number%.zip
like image 22
TheCodingHatter Avatar answered Jan 04 '23 05:01

TheCodingHatter