Remove directory structure in Teamcity's artifacts
Asked Answered
D

3

17

I use Teamcity to build different packages and want to save those Packages as Artifacts. My Artifact Path in TeamCity is the following:

%system.teamcity.build.workingDir%\**\Release**/*.wsp => Solution 

Now TeamCity collects all WSP-Files in any Release-Directory after building correctly. But it is saved including all subdirectories like:

How the Files are being offered

I only want the .wsp-File directly under "solution" without the directory tree.

Deplume answered 26/10, 2011 at 12:56 Comment(0)
B
7

From TeamCity docs:

wildcard — to publish files matching Ant-like wildcard pattern ("" and "*" wildcards are only supported). The wildcard should represent a path relative to the build checkout directory. The files will be published preserving the structure of the directories matched by the wildcard (directories matched by "static" text will not be created). That is, TeamCity will create directories starting from the first occurrence of the wildcard in the pattern.

http://confluence.jetbrains.net/display/TCD65/Configuring+General+Settings#ConfiguringGeneralSettings-artifactPaths

In your build script ( or additional final build step) you will have to copy the necessary files to a single folder and publish that folder as Artifacts

Behaviorism answered 26/10, 2011 at 16:21 Comment(5)
I wrote a tool which recursivly collects the files. That did the job. Not the best solution, but "a" solutionDeplume
@Max Klinger: There's a tool called PowerShell that's good for making 'tools like that :DSpirillum
maybe. But programming in CS was faster :)=Deplume
If you look further down in that TC doc, there are examples and one of them seems to say that you can flatten a folder structure (all *.x files in subdirectories go to the root of the target): target//.txt => docs* — publish all the txt files found in the target directory and its subdirectories. The files will be available in the build artifacts under the docs directory. Not sure what that syntax is though. Certainly does work on a windows TC server.Modernism
The example that @Modernism mentions is target/**/*.txt=> docs, but it doesn't flatten the directory structure, it merely replicates that structure underneath a directory called docs. Elsewhere in the TeamCity docs, it is explained that when using wildcards (either * or **), "The files will be published preserving the structure of the directories matched by the wildcard (directories matched by "static" text will not be created). That is, TeamCity will create directories starting from the first occurrence of the wildcard in the pattern."Doubler
S
4

Instead of copying as @manojlds suggests, you might be able to achieve something by modifying the OutputPath in yout .csproj file, or feeding in an OutDir property override when building a .sln (if you are). Be warned that neither of these approaches are perfect - for example, TeamBuild (the CI server in the Visual Studio ALM Tooling) redirects everything into one directory, which can cause a complete mess and only works for the most simple cases.

Spirillum answered 29/10, 2011 at 7:30 Comment(1)
Care to explain why this is worthy of a downvote? Why not upvote the other one? Or what am I missing? Do you think it should be a comment? Its a good idea to try to explain your thinking when downvoting.Spirillum
M
4

I had this issue where I wanted to gather various install files from subdirectories. Adding a PowerShell runner as a build step is quite powerful and solves this nicely...

get-childitem -Recurse -Include *.wsp | Move-Item -destination .

This will move them to the root prior to TeamCity looking at the artifacts, where the basic artifact paths like *.wsp can pick it up for the final output.

Maloy answered 12/6, 2015 at 7:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.