How to check in the artifacts into tfs

I have a requirement that I must check in the artifacts from teamcity.

I have teamcity set up so that it gives me the correct files as artifacts.

But now I have to be able to take these files and check them in into TFS under a differant folder (under the main working directory).

So say I have:
Mainfolder
     - binaries
     - projectfolder
     - solution file

I can get teamcity to build and take the needed files and publish them as artifacts but I also want to copy these artifacts and put them into the 'binaries' folder and check them in into TFS.


I'm using the latest version of teamcity.

Any help would be appriciated

Tom

5 comments
Comment actions Permalink

Hi Tom

You can run this checkin command explicitly in additional command-line build step.

Please also check that your build configurations are configured to use agent-side checkout.

Michael

0
Comment actions Permalink

The problem I'm having at the moment is that I can't get to the artifacts path.

I'm sure there is a variable for it but I can't seem to find it.


Concreet:

My artifacts are located on: C:\TeamCity\BuildServer\system\artifacts\TestUnitPublishing\TestUnitPublishing\56\Binaries

Where as my checkout directory is: C:\TeamCity\TeamCity\buildAgent\work\f7489a7f0e67b2d9\Binaries

(the server is currently installed on my local machine for testing)

So I need to get the artifacts into the checkout directory otherwise TFS doesn't want to check them in.


If I can get to the artifacts from within a command line build step and can copy them to the checkout dir I can start to look into checking them into TFS


Any help with this will be appricated

0
Comment actions Permalink

Tom,

Your build scripts should not access files inside TeamCity data directory at C:\TeamCity.
Now the build is executed on the same machine as TeamCity web server is installed, but laterwhen you add new build agents on other computers, it will stop to work.

It's better to keep build scripts isolated and portable. The artifact files are created within checkout directory, so you can use relative paths to access them.

0
Comment actions Permalink

I know and currently I'm not using the artifacts at all because of that.

Maybe if I explained the current setup (that does work but is far from perfect I think) it might be a bit clearer.

General settings:
- artifacts paths:
     TestUnitPublishing\bin\release\*.exe => Binaries
     TestUnitPublishing.Tests\bin\release\TestUnitPublishing.Tests.dll => Binaries

Version control settings:
- vcs checkout mode: automatically on agent
- checkout directory: auto

Build steps (7) (step 1-4 aren't the problem I think)
- build solution (basic visual studio build)
- ms tests
- nunit tests
- inspections (.net)
- command line step to checkout the files from tfs (needed otherwise I can't check them in (permissions and such))
     d:\software\tf\tf.exe get %system.teamcity.build.checkoutDir%\Binaries /recursive
     if EXIST %system.teamcity.build.checkoutDir%\Binaries\TestUnitPublishing.exe (d:\software\tf\tf.exe checkout      %system.teamcity.build.checkoutDir%\Binaries /recursive)
- copy artifacts step (here is where I can't access the artifacts so I just do a copy of the build output in my release folder)
     Copy %system.teamcity.build.checkoutDir%\TestUnitPublishing.Tests\bin\Release\TestUnitPublishing.exe      %system.teamcity.build.checkoutDir%\Binaries /Y
     Copy %system.teamcity.build.checkoutDir%\TestUnitPublishing.Tests\bin\Release\TestUnitPublishing.Tests.dll      %system.teamcity.build.checkoutDir%\Binaries /Y
- checkin from binaries
     d:\software\tf\tf.exe add %system.teamcity.build.checkoutDir%\binaries\TestUnitPublishing.exe
     d:\software\tf\tf.exe add %system.teamcity.build.checkoutDir%\binaries\TestUnitPublishing.Tests.dll
     d:\software\tf\tf.exe checkin /force /noprompt



When I go and look at my local system the artifacts aren't anywhere to be found in the checkout directory.
I assume that the directory under buildagent is my checkout directory:
     C:\TeamCity\TeamCity\buildAgent\work\f7489a7f0e67b2d9

But I can find them under the buildserver directory:
     C:\TeamCity\BuildServer\system\artifacts\TestUnitPublishing\TestUnitPublishing\98\Binaries



As I said I got it working but I find a bit counterproductive since now if I have a new dll or any other artifact I have to change the configuration at 2 stages (under general settings the artifacts paths and in my build step so it gets copied to the correct folder for checkin)
I'd much prefer that I can change the copy artifacts step to just copy all the artifacts to that binaries folder.

Unless there is a other way to do this, I'm new to teamcity so I might have overlooked some setting that would make it all easyer.

0
Comment actions Permalink

Tom,

Sorry for the delay in replying.

OK, so the issue seems to be that you want to configure artifact patterns in a single place and then use them for defining TeamCity artifacts and inside the build script to check the files into TFS.

I can think of the following options:
- store artifacts definition in a TeamCity system property, reference it in the artifact patterns field (with %system.name% syntax), get the property in the build script and use it there, or
- store the patterns in the build script, prepare artifacts in a directory, check them into TFS, make TeamCity publish artifacts from the same directory with a simple "publish all from the directory" pattern, or
- move the artifact checkin into TFS into a separate build configuration, which will artifacgt- and snapshot-depend on the one producing artifacts. Trigger this publishing build configuration instead of the one producing artifacts.

0

Please sign in to leave a comment.