I need to put several folders into artifact archive. Now I am doing it the following way:
P3Binaries/bin => build %env.BUILD_NUMBER%.zip!/bin
P3Binaries/DemoFiles => build %env.BUILD_NUMBER%.zip!/DemoFiles
But I don't want to duplicate archive name (a real name is even more complicated). Is there any way to store it to some variable an reuse?
Yes, you can store this value in the build configuration parameter and reuse it.
Defining and Using Build Parameters in Build Configuration
Related
On mvn install, a directory get created in target whose name contains buildnumber/timestamp.
Now I run mvn assembler where I need to use the same directory. I can not recreate the name since timestamp would change.
How can I retrieve the file name? I know the location of the file in my project.
Bind maven-assemlby-plugin into the build life-cycle and let it run with the usual build and you have your information available during the assembly creation.
I'm writing a Maven project and I'd like to include a file in the generated WAR that will contain some build time information. Typically this will be things like
The build time/date stamp
The user name of the person who built the WAR
The version of the app as specified in the POM
These are all fairly easy as there are maven properties which will give me the information I need.
I'd also like to include the machine name. I know Windows stores this information in an environment variable called "COMPUTERNAME", while *nix uses the hostname command.
Is there some platform independent way of grabbing this information so that I can write it into my text file?
I did this by invoking the Maven Ant task. Within that I used the following Ant tasks:
<tstamp> to generate a timestamp property
<propertyfile> to create a properties file containing properties like the above timestamp, the username etc.
You could use the Ant <exec> task to execute hostname and nominate an output property to write this value into.
This created a properties file in the src/main/resources dir that I then embedded in the .war file
As Andrew Logvinov says,
Look up hostname from Maven
Thanks :-)
I build j2ee aplication as WAR with teamcity.
I want keep the same WAR name and save build parameters in produced artifact.
What the best way to save teamcity build parameters (like build.number, svn.revision, buiild.date etc) inside it?
Something like
echo build.number=%build.number% > prop.properties
is what I do in a TeamCity build step to directly record parameters to a file.
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
Newbie question : I have 2 C# projects in TeamCity, call them A and B. A contains a reference to B.dll. B builds fine. However, A fails to build because it cannot find B : Could not locate the assembly "B"
It seems really simple : how do I tell my project A on the buildserver where to find the binaries from B\bin\Release?
You do this by creating 'Artifacts' and artifact dependencies.
If project A is dependent on project B, then you create an Artifact on project B using an artifact path like so:
bin/Release/B.dll
Then on project A you setup a artifact dependency on B with path like:
B.dll
And set the destination path to be where ever project A is expecting to find B.dll e.g.
./Libs
You can do other cool stuff like automatically archiving all your artifacts into a zip by using the syntax:
bin/Release/*.dll => B.zip
and access them via:
B.zip!B.dll
All these paths are relative to build directories so makes it easy and you dont need to worry about the TeamCity guid folders or use absolute paths.
The problem you're encountering is that Teamcity runs each build in it's own temporary directory and since this is a randomly generated name you can't set a reference directly from one to the other.
Typically you would write a build script that builds both A and B in the right order and just have Teamcity run that build script. (Since you're using C#, MSBuild is ideal for this).
The alternative would be to have B.dll copied to a known location (e.g. c:\currentbuild) at the end of its build and have A always reference it from here. You can set up build dependencies in Teamcity so that if B is rebuilt, A is also rebuilt.