build artifact filenames in build script variables/parameters?
Hello.
I would like to know how one can use artifact names in TC build steps as variables/parameters.
Practical use case: Step 1 contains a maven build producing an JAR with changing file name (which has e.g. the version number in it), but always found as defined artifact. Step 2 is a shell script that should using that file name as a parameter.
NB: just the name, not the file itself. I found the article on how to access build artifacts by constructing URLs. That is not what this question is about.
Please sign in to leave a comment.
The article you found on accessing build artifacts is super old; from TeamCity 7!. The latest way (and recommended way) of accessing build artifacts is using the TeamCity REST API as described in REST API - Get Build Artifacts.
However, if both steps are within the same build configuration, TeamCity server won't be aware of the artifact until after the build has been completed. So there won't be any REST API methods available to get the artifact names until the build has finished.
What is the constructor used to name the artifact in Step 1? Can you create a build parameter in your build configuration with the same constructor? For example, if the version number is based on the build number, I would add a build parameter like this:
There are also probably other ways of accomplishing the same task. If the above is not suitable, please share more details or an example of your use case.
Thank you for your response. As for the REST interface, I am not looking for the build artifacts themselves.
The maven build (and its like, I may add) constructs the file name from the build parameters; for maven, that's the pom.xml ; entries
causes the artifact to be named "someFile-0.5.8-SNAPSHOT.war". (for gradle e.g., see build.gradle - I think this pattern repeats)
This is changed in source commits, the build configuration stays unchanged.
The artifact generated is reliably found and used (e.g. in deployment or packaging) using wildcard patterns.
For example, an scp build step may copy "someProject/target/someFile-*.war=>javaweb/" - this sort of thing works fine.
What I am asking for is a way to use the artifact names in non-specific build steps. Test case being: command line build step which should "echo" the artifact names to stdout.