need help capturing build number of the build?
Hello all,
Is there anyway that we can capture the build number/version after the build artifact is deployed?
PROBLEM:
When we deploy a new build to our system, there is currently no way for us to know exactly what build version is deployed after the fact. Is there a way that the build server can add something to the build, where we can then look on the system to see what version is running.
*****************
i can see that in build log, it does mention about build number, but does it store that information anywhere? Is there anyway to retrieve that information in deployed system?
Thanks
Please sign in to leave a comment.
in your build process, create a file with the information (MANIFEST for java, or properties file) and add it to the package. This way the build information (number, date, links) will be present on the servers, when you deployed the package.
regards
ziv shapira
Thank you for the reply.
So, by doing this, does Teamcity let us add build number to the rpm artifact. like: artifactID.0.0.2.snapshot.BUILDNUMBER.rpm or something like that ?
What Ziv said is a valid solution and I have used that technique myself.
However if you can detail what your deployment is. eg. Jave .. .net etc, there maybe alternative and better ways of keeping tack of your releases
Stewart H
Yes, during the build process you have access to all the teamcity properties, such as %build number%.
1. you can use them to name the rpm that you are building
2. you can write them into a properties file, which you then include in the rpm, to identify it's build origin (you can add there any info you like)
thank you for your quick reply. can you also tell at which (setting) step we can access those properties. is there any samples that i can look at?
thank you for your quick reply... i will try that..
I'm trying to tackle this exact issue today. Nikunj, did you ever find an example of TeamCity incorporating the version and build number into the built artifact's file name? But, more to your point, being able to use that information "after the build artifact is deployed"?
My situation isn't unique, but is probably not exactly like yours. Nikunj, I'd like to document what I find within your thread. Let me know, and I'll start a new thread if you want.
--
Marshall.7.0.16493.me
Hello MrMarshallMan,
i haven't found the samples yet. i was also looking for these information so that we can use the information after build artifact is deployed.
you can continue with this thread too. if you decide to start new thread then please send me a private message with the link.
Thanks
Hey Nikunj,
There's probably 100 different ways this can be done if you take into account:
I created a test project, with no real code, and just a command line build runner.
build.cmd
source.txt
test.cmd
version.txt
Without TeamCity, the raw commands for this test project are:
> build.cmd
creating: builtArtifact-0.1.txt
> test.cmd builtArtifact-0.1.txt
Success.
The solution I found/choose was to use the Build Script Service Messages. It has the benifit that I didn't have to alter the original build.cmd / makefile. The only downside I can see is that the standard incrementing build number used by TeamCity is now replaced with the build script service message I created by pulling in the contents of version.txt. But, this is a first draft, and I'm sure a few tweeks could have this in a much more stable state.
Edit: I found what I needed, note the change in the command below.
I hope you can extrapolate a solution from what I just gave. If not, let me know. I still need to solidify a decision about how I want to handle this for my projects.
Take care,
Marshall.7.0.16494.me
Hi MrMarshallMan and nikunj
Neither of you have indicted what your build artifact or deliverables are.
If you are building .net projects then TeamCity provide a convenient build feature call Assembly Patcher see http://confluence.jetbrains.com/display/TCD7/AssemblyInfo+Patcher
This results in the version number of the resulting DLL's and Exe's being set
Stewart
oh my bad, its a java project, build server operates on Linux. we use maven and trying to use maven rpm plugin to create RPM, and deploy RPM, jar and java doc.
Stewart,
By design, I kept my response as build runner agnostic as possible. However, at the moment, the project I'm working on does use a command line build runner.
--
Marshall
Hi
For Java, add a step in your build script that creates a manifest file, and then add it to the JAR that is built. Afterwards, you can access the information from the JAR, where it is deployed and see the build number.
http://docs.oracle.com/javase/tutorial/deployment/jar/packageman.html
regards
Ziv Shapira