In this tutorial, we’ll talk about artifact rules in TeamCity. Artifact rules are simple, but there are a few nuances to consider.
In this build, when we hover over the artifact icon, we can see that there are two artifacts with no folder structure: the application log file and a Selenium .mp4 recording.
When we go over to Build Configuration settings | Artifact paths, we can see that both artifacts
come from a directory: calculator-service/artifacts/*
.
There are different options available to specify Artifact paths. For instance,
+:**/* => target_directory
-:directory1 => target_directory
will tell TeamCity to publish all files except for directory1
into the target_directory
.
In our example, we’re telling TeamCity to include everything inside the calculator directory and then put it into an artifact folder that every build has. This folder might be stored on Amazon S3 or any other storage provider.
These two lines are equivalent:
Let’s specify a different artifact path. Instead of including everything in the artifacts
subfolder, we’re going to tell TeamCity to move the files to another_directory
. We’re also
going to exclude every .log
file from being copied to the storage.
Since these rules are additive, we’re telling TeamCity to include every file and move it to another
directory. In addition to this, we’re also telling TeamCity to exclude .log
files.
To finish it off, let’s add another rule:
+:calculator-service/**/application.log => hello_world/whatever.log
With this rule, we’re telling TeamCity to take the application log application.log
from
every subdirectory **
in the calculator-service
directory and put it into the
hello_world
folder. We’re also telling TeamCity to rename the application.log
file to whatever.log
.
Once we save the changes and run the build, we can see that our artifact storage paths have changed. We now have different folders and subdirectories that our artifacts are stored in:
Make sure to check out our other tutorials on creating your first build pipeline and sending build information to external platforms like Jira.
Happy building!
For more information, see our TeamCity artifact dependency documentation.
Learn what an artifact repository is in the TeamCity CI/CD Guide.