How do I copy files from a folder to the same folder in the target archive?
Below is what I came up with based on the documentation.
file_name|directory_name|wildcard [ => target_directory|target_archive ]
%env.PROJECT%/EnvironmentSpecificAppSettings/* =>EnvironmentSpecificAppSettings | ..\..\..\..\..\..\..\Artifacts\CI\Website.%system.build.number%.%system.build.vcs.number.PROJECT_CI%.CI.zip
I know of three options.
As sharma noted, you can use artifact paths in General Settings, which will allow you to describe a mapping of files on the buildAgent to files in the archive. You can use absolute or relative paths here. I don't think I've ever tried using property expansions there.
You can also use service messages - by emitting a message with a special format to output, you can issue a number of different commands to TeamCity, including a command to publishArtifacts
You can also use a simple file copy in your build to the appropriate directory in the archive. TeamCity sets properties with the names of the folders that you will need - teamcity.buildConfName, teamcity.projectName, teamcity.agent.dotnet.build_id, etc.
If you are talking about the artifact paths in General settings. Suppose you want the fodler 'Artifacts' in check out dir of the teamcity to be generated as artifacts in Artifacts.tgz then you may want to say:
%system.teamcity.build.checkoutDir%/Artifacts => Artifacts.tgz
Related
My last build step in my TeamCity 9.1 project configuration uses the SMB deployer to copy files to a shared network drive (which we use to deploy the version to our users).
The copy is performed fine but the deployer somehow creates all the folders in the hierarchy leading to the bin folder. Example:
My configuration is:
Target URL:
\\theserver\thefolder
Artifacts path:
**\ProjectName\bin\Release\* => .
**\ProjectName\bin\Release\Resources\* => Resources
With this configuration, I'm expecting the files to be copied to \\theserver\thefolder\* and \\theserver\thefolder\Resources\*
However, this is the result I get instead: my files are copied to
\\theserver\thefolder\ProjectName\bin\Release\*
\\theserver\thefolder\Resources\ProjectName\bin\Release\Resources\*
How do I go with my artifacts definition so my files are copied to the proper folder? I'm having such a hard time with this syntax
The **\ prefix is causing the artifact path output to include the matched folder hierarchy.
You'll need to use the full path to the Project folder, also if you want to include nested directories, use the **\* at the end of the artifact path:
\path\to\ProjectName\bin\Release\**\* => .
\path\to\ProjectName\bin\Release\Resources\**\* => Resources
For more information, see the artifact path doco, specifically:
wildcard — to publish files matching Ant-like wildcard pattern (only "*" and "**" wildcards are 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.
For a .NET Developer, the Teamcity artifact paths are not very straightforward.
Per project I do, I have a folder called BuildTools and, within it, folders called Drops and Inputs (drops being the reports and outputs inputs being the config files for various command line apps).
BuildTools/Drops/NDependOut => GenericSolution/Drops/NDepend
Is this correct? BuildTools is from the root of the (custom) checkout dir, and then GenericSolution is from the root of the artifacts path (Called "Artifacts" folder).
The other problem I have is that the NDepend report has a lot of images etc in the same folder as the .html file. How would I upload this? Do I upload the entire folder (in which case, is the syntax above correct?)
In general this is right. TeamCity has an option to zip artifacts before publish. For that use the following syntax
Folder/folder/*/ => destfolder/archive.zip
Another trick is to use TeamCity service message to publish artifacts dynamically from build script.
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:
I only want the .wsp-File directly under "solution" without the directory tree.
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
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.
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.
I have the following sample / test configuration that has Hudson create a directory of empty folders. Its then instructed to archive everything within that folder, except it will not match empty folders and ends up archiving nothing. Whats more annoying is that Hudson does not alert you that nothing matches the search string "root**", but when it builds, it says nothing matches the search string.
(source: 86th.org)
We need Hudson to archive these empty folders for our installer since its expecting them. I fear this may not be possible because of the text "Files to archive".
At any rate, How can I configure Hudson to archive empty folders as an artifact.
You should create the artifact that you want in your build scripts, and then have hudson archive that file. So if you want a zip file that contains empty folders, do the appripriate zip command in your batch file or ant script. Then archive the output file.
Looking at the Hudson source code, it seems as if artifact archiving is meant to only match against files.
You might want to file a feature request or send an email to the USERS list, the Hudson team is pretty good about replying to requests and/or adding features in new releases.
I see three ways:
have your application NOT expect the folders but create them on demand.
or have the application create the folders at startup.
or you could just add dummy files in the folders :) just thinking out of the box.
I'm trying to label a build that is made of multiple checkouts like this:
+Root
+-trunk
+--Folder1
+--Folder2
+-Tags
+--ProjectA
+---Build-123
+----Folder1
+----Folder2
where 123 in Build-123 is the build number.
I'm trying to achieve this by using the following labelling rules:
/Root/trunk/Folder1=>/Root/tags/ProjectA
/Root/trunk/Folder2=>/Root/tags/ProjectA
And this labelling pattern:
BUILD-%system.build.number%
I was hoping that TeamCity would create the BUILD-123 tag and copy the contents of Folder1 and Folder2 into it. However I get the following error:
Failed: Failed to set label 'BUILD-123': Svn labeling failed: Cannot copy 'Root/trunk/Folder1', 'Root/trunk/Folder2' to the same directory 'Root/tags/ProjectA/CO-BUILD-123'
I'm using TeamCity 5 with Subversion 1.6
This seems to be a limitation on SVN side. The only solution I've found is to call SVN directly to create the destination folder first (mkdir) then use svnCopy to copy each source into that folder.
It seems we need to have labeling rules such as
trunk => tags # the trunk contains the root of my project
branches/*/ => tags # a branch usually contains the a copy of the root of the project
tags/*/ => tags # a tag usually contains the a copy of the root of the project
this will enable (re)tagging branches and tags without explicitly setting their names.
unfortunately TeamCity does not have such generic rules
Please read TeamCity's docs about this topic:
I suppose you need rules like
/Root/trunk=>/Root/Tags/ProjectA
or
/trunk=>/Tags/ProjectA
depending on where you repository root is.