How do I get this command line script to work in TeamCity? - tfs

I finally got a msbuild to execute and do a publish through the command line. Now I'm wondering how do I do that via teamcity?
When I run this command line it works!
C:\TFS\project\myProject\APIproject>msbuild apiproject.csproj
/p:DeployOnBuild=true
/p:PublishProfile="Properties\PublishProfiles\DEV.pubxml"
/p:VisualStudioVersio n=14.0
However, I don't see a good solution in TeamCity to run this script.

See the documentation: add an 'MsBuild' build step and populate the fields appropriately. Your commandline translated to these fields:
'Build file path' relative/path/to/apiproject.csproj
'Targets' I'm guessing 'Build' but can be left empty for the default
'Command line parameters' here you can specify all properties like on the commandline. TeamCity might emit warnings because you do so, because the alternative and preferred way is to make all these properties TeamCity build parameters: TeamCity passes build parameters to MsBuild automatically.

Related

Specflow tests in teamcity

How can I configure the build process in TeamCity to execute SpecFlow tests?
I am using visual studio 2017 with the Specrun.Specflow nuget package installed.
Can it be done with Nunit or SpecRun.exe?
To run the SpecFlow tests with the SpecFlow+Runner (aka SpecRun), you need to do this:
Open your project's build steps.
Click on Add build step.
Choose "Command Line" from the dialogue.
Configure the build step as follows:
Run: Executable with parameters
Command executable: Enter the path to SpecRun.exe here
Command parameters: Enter the command line parameters for SpecRun.exe here. Use the BuildServerRun option and include /buildserver:teamcity.
Information on executing command lines in TeamCity is available here. More details on the
SpecFlow+ Runner's command line options can be found here.
Click on Save.
Taken from https://specflow.org/plus/documentation/SpecFlowPlus-and-TeamCity/

TFS build renaming the cspkg file

I currently use TFS build for my Azure cloud service project.
as a output of that .cspkg and .cscfg file is created after the successful build.
is there any way to add the $(Build.BuildNumber) to my .cspkg file
say for eg: currently my output file looks like
SchoolWebPortalAzure.cspkg
is it possible to rename like SchoolWebPortal_1.0.0.1.cspkg in the tfs build definition.
thanks,
kind regards,
Snegha
You could use the Run Command Line task or do it in a PowerShell script in build.
1). Add the Inline Powershell task from the marketplace before the copy task in build definition.
2).Enter the following Powershell in the text area
Param (
[string]$pathToFileToRename
)
Rename-Item $pathToFileToRename Helloworld_$(Build.BuildNumber).exe
3). Enter any required arguments in the arguments text box (you could
use environment variables) e.g. -pathToFileToRename $(Build.SourcesDirectory)\somepath\CurrentName.exe
Then you will get the renamed file in the drop folder.

Pass a dynamic parameter in Jenkins build

I want to pass a dynamic parameter in Jenkins in a scheduled job (this build runs every day at 3:00 am)
This works if I executed it in my linux command line:
mvn package -DintegrationTag=$(date +%d-%m-%y)
or
mvn package -DintegrationTag="$(date +%d-%m-%y)"
or
mvn package -DintegrationTag="$(date +"%d-%m-%y")"
with these 3 options this is what is executed, for example (this is what I want to do in Jenkins):
mvn package -DintegrationTag=16-09-2013
but any of these sentences, do not work in my Jenkins goals and options (because the dynamic parameter).
Is there any way to do it?
The solution:
Content of the file which constains the script:
echo "NOW=`date +%d-%m-%y`"> env.properties
Path of the properties file:
env.properties
In project, goals and options:
clean test package -DintegrationTag=$NOW
Inject environment variables to the build process = true
In a Build "execute shell" section add this
NOW=`date +%d-%m-%y`
mvn package -DintegrationTag=$NOW
Another option can be to execute a top level maven target in jenkins.
The first two steps of injecting the required variable value into the build environment remains same as the answer given by #Iker below.
In the third step, give goal as
clean test packageand then in Properties section within the 'Advanced' tab, giveintegrationTag=$<your variable name>
Note that this solution is useful when one creates a free style project in jenkins. For maven 2/3 projects,solution by #Iker is good:)

Jenkins on Windows using something other than ant

I am looking at using Jenkins on Windows.
I currently have an ant script. It works pretty well. Except for instance, when the build breaks because of a syntax error, I can not see the error in the Jenkins console log.
So I am thinking may be ant is not the best tool for use on Windows.
What do most of you use for Jenkins on Windows?
If it is ant, how do you send the build output, VStudio, to the Jenkins console?
Thanks
Primarily I use Jenkins with maven projects, although you should see the ANT output in the online logs regardless.
What are you building? Are you building Java projects? Ant is what you use. If you are bulding a C project, you should use Make. If you're building a VisualStudio project, you should use msbuild. You use the build tool for your project. Jenkins will execute them without a problem.
Take a look at the build in question. On the left side of the screen, there's a Console output item. Click on that. Is there any output. No matter what tool you use, Jenkins captures the STDOUT and STDERR in that console output. If nothing else, you should see the exact commands Jenkins is executing to checkout and to build your project. Try executing those commands.
Still, you didn't give us much to go on. No idea what you're building or what you're doing with Ant. You didn't state any error, the console output, or even what the Jenkins error log is stating.
Jenkins does two things:
It watches your repository for changes.
Once it detects the changes, it executes the very commands you'd execute to build the project.
Jenkins doesn't care whether you use Ant, Maven, Make, or simply do a del /s/q. Jenkins will simply execute the commands you tell it to execute.
Addendum
It is c, c++, Java and InstallShield. I use ant to do file copy and move, call msdev.exe project. Some Javac calls, InstallShield command line builds..
Jenkins can execute multiple step builds in a single job. After you specify the build step, you can press the Add button to add another build step. There's no reason that all the build steps even have to be of the same type. Just select a "Freestyle" build, and use the right build tools for the job.
There's an optional MSBUILD plugin in Jenkins that should do your MS Build. This should give you the complete output from MSBuild, so you can see any errors.
After you do your MSBuild step, you can create a second build step to run an Ant task to build your InstallShield. After that, you could run another build step to do the copying you need either on the command line or through something like Ant (or Nant.
Whatever the output of the various tools is the output you'll get in the build console.
dev.cmd shows the output and I continue to use ant.

Pass a command line argument to Ant in Hudson

I'm trying to pass a -lib argument to ant as part of an automated build using Hudson but can't see a way to do this. I could add the relevant libraries to the ant/lib folder but that would then mean the same version of the library necessarily being shared by all builds on that machine.
Any help much appreciated.
In your Hudson job configuration you can specify ant arguments such as -lib in the Targets field. See the help message that opens when you click the ? next to the Targets field.

Resources