How to name build steps in Buildbot - buildbot

I have Buildbot set up on a Windows 7 machine that's set to run a series of tests when I check in python code to a git repo. When I check on the build details via the web interface it displays a set of build steps that have been run as defined in my master.cfg configuration file.
Currently I have several shell command steps that each run a windows .bat file. Each of these steps is sequentially titled "shell", "shell_1", "shell_2", etc. Is there a way to re-name these steps (i.e. "format_check", "unittest", etc.)? I don't see an option to name build steps in the "build steps" section of the buildbot documentation.

Generally you just add it as a parameter in the call to addStep: e.g. name="step_name"
Updating the referenced documentation's examples to include a name parameter:
f.addSteps([
steps.SVN(repourl="http://svn.example.org/Trunk/", name="svn"),
steps.ShellCommand(command=["make", "all"], name="make"),
steps.ShellCommand(command=["make", "test"], name="test")

Related

TFS 2015 Build step Nuget Publisher "Ambiguous option 's'"

OK, so we're stuck on on-site TFS2015 at the moment. My Nuget Publisher build step is failing with:
##[error]Ambiguous option 's'. Possible values: Source SymbolSource SymbolApiKey.
It appears inside the build step they have put -s instead of -source, and in later versions they've added more commands starting with s. So what are my options?
Write my own in Powershell (Can do, but TFS Build is very clunky for this)
Find wherever this is defined in TFS (hopefully a template .ps file) and fix it there (Anyone know where this is kept?)
Upgrade to a later version of TFS (a fairly large, but perhaps inevitable undertaking)
Somehow override the -s command another way?
????????
Invoke NuGet.exe however you'd like via the Command Line task
If you did #3 (upgrade TFS), you'd find that the PowerShell build task can run an in-line PowerShell script, making it significantly less clunky.
You may be able to extract and modify the task with the tfx command line utility, but I can almost guarantee this will have nasty ramifications when you do eventually upgrade.
I'm adding my answer for details about step 5 maybe it will help team that are still using TFS 2015.
Nuget Publisher seems to use old version, which means "-s" option will not work.
To bypass this situation you can setup your build as follow:
1- Add Nuget Packager Step and specify the the Package Folder value:
2- Add a new step which would copy your artifacts(Note that contents that should be copied must end with nupkg):
3- And Finaly you can just run a command line that will perform the publish operation. In my case we are pushing the whole repository using init command(PackageRepository is the path to our internal feed that we set in we've set in Variables section):

Analyzing non-Visual Studio, Unity C# code with MSBuild/SonarQube via Jenkins

I inherited the responsibility for a SonarQube Linux server which was running version 5.1 and analyzing dozens of Unity C# projects. After upgrading it to SQ 6.1 I discovered that support for analyzing C# projects on non-Windows systems was dropped in version 5.5, so I downgraded it to version 5.4 for the present time.
I have subsequently set up a Windows system as a Jenkins node and SonarQube server. However, the projects I am hoping to evaluate with SonarQube are (mostly) developed on and (always) built on macOS in Unity and therefore lack MSbuild solution files. Is it at all possible for me to use SonarQube within these constraints, short of adding Visual Studio-specific code to the projects? Is there some kind of dummy solution file that I could add to the projects that would allow them to be analyzed without the expectation of a working binary being produced (along the lines of parsing/tokenizing without compiling/linking)? Thanks.
Here is the procedure I have developed for analyzing Unity projects in SonarQube via Jenkins.
A user-facing Jenkins job with the following settings and options, among others specific to my environment.
General—This project is parameterized
String parameter PROJECTKEY
String parameter PROJECTNAME
String parameter PROJECTVERSION
General—Restrict where this project can be run set to the Jenkins build node name you used for your SonarQube server.
Source Code Management
Repository URL set to the repository you want to analyze.
Branches to build set to the main branch, i.e. refs/heads/master.
Additional Behaviors—Recursively update submodules checked as appropriate for your repository.
Build Triggers
Poll SCM checked, but no schedule specified.
Build Environment
Run buildstep before SCM runs—Inject environment variables set to HOME=C:\Users\Jenkins (or as appropriate for your system). This environment variable makes it possible for git to find the correct ssh credentials to use with the Git server. You'll need to put your git private key in %HOME%\.ssh; that is documented elsewhere and left as an exercise to the reader.
Use build environment from another project—Template Project pointing to a second Jenkins job. Mine is called SonarQube_Scanner (see below).
Build
Use builders from another project—Template Project pointing to the same Jenkins job SonarQube_Scanner.
Post-build Actions
Archive the artifacts—Files to archive set to log.zip.
A non-user-facing Jenkins job (SonarQube_Scanner) with the following settings and options.
General—Disable this project checked.
General—Restrict where this project can be run checked and set to your SonarQube server.
Source Code Management set to None.
Build Environment—Inject environment variables to the build process checked.
Properties Content contains
`LANG=en_US.UTF-8`
Build
Execute Windows batch command contains
set FILENAME=%WORKSPACE%\client\Assets\Editor\SQMenuItems.cs
REM Yes, this syntax works and is sooo much more readable
> %FILENAME% ECHO using UnityEditor;
>> %FILENAME% ECHO public static class SQMenuItems {
>> %FILENAME% ECHO static void AssetsOpenCSharpProject() {
>> %FILENAME% ECHO #if UNITY_5
>> %FILENAME% ECHO EditorApplication.ExecuteMenuItem("Assets/Open C# Project");
>> %FILENAME% ECHO #else
>> %FILENAME% ECHO EditorApplication.ExecuteMenuItem("Assets/Sync MonoDevelop Project");
>> %FILENAME% ECHO #endif
>> %FILENAME% ECHO EditorApplication.Exit(0);
>> %FILENAME% ECHO }
>> %FILENAME% ECHO }
"C:\Program Files\Unity_5.5.2\Editor\Unity.exe" -quit -batchmode -nographics -logFile "%WORKSPACE%\log.txt" -buildTarget android -projectPath %WORKSPACE%\client -executeMethod SQMenuItems.AssetsOpenCSharpProject
"C:\Program Files\7-zip\7z.exe" -tzip a log.zip log.txt
SQMenuItems.cs is what triggers Unity to create the .sln and .*proj files that MSBuild needs. The .sln and .*proj files are typically in the .gitignore file and therefore not in the repository.
SonarQube Scanner for MSBuild - Begin Analysis
SonarQube Installation set to the Jenkins build node name you used for your SonarQube server.
Project key set to ${PROJECTKEY}.
Project name set to ${PROJECTNAME}.
Project version set to ${PROJECTVERSION}.
Additional arguments
/d:sonar.exclusions=**\\SQMenuItems.cs
Execute Windows batch command
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /maxcpucount /nr:false /nologo /target:rebuild /verbosity:quiet client\client.sln
You may need to change client\client.sln above to match your environment. I haven't yet tried replacing that with an environment variable defined in the user-facing Jenkins job.
SonarQube Scanner for MSBuild - End Analysis
DONE
GOTCHAS
If the job fails because Unity fails because it can't find the projectPath, it may have forgotten its license key. Remote desktop to your SonarQube server and launch the Unity GUI. If it pops up asking for your license key, re-enter the key, then quit. Subsequent jobs should succeed.
Things that make it very difficult to pass information to SonarQube in a dynamic way.
Windows environment variables defined in 2.5.1 “Execute Windows batch command” are not preserved through to 2.5.2 “SonarQube Scanner for MSBuild - Begin Analysis”.
The SonarQube.Analysis.xml file specifically prohibits assigning the properties sonar.projectName, sonar.projectKey, and sonar.projectVersion.
I've probably overlooked something; please don't hesitate to inquire.

Cannot deploy web.testing.config to the build server

I am learning TFS 2010 from scratch and no doubt making every mistake in the book.
I have created a web.testing.config for my build to the test server.
In my build process I click the plus sign for "Items to Build" in "1. Required" and I specify "Any CPU | Testing".
The build clean compiles but ... I still seem to be using the web.config file I use in development rather than the one I want in testing.
The first line in web.testing.config is
This should ensure that any differences in this file are implemented.
So I am not sure I am configuring the build properly, or if the web.testing.config is set properly.
What you are looking for is a feature called web.config transforms, and it works slightly differently.
In Visual Studio right click on web.config and choose option Create Tranforms -- if you have not done this already.
Read samples on using tranform syntax, the link is in the web..config created for you. You will need it.
In TFS team build, create a separate step in your build template to build deployment package. The command is in this thread. This will create a deployment package -- a file with .zip extension.
To deploy the package, use WebDeploy tool. It has both UI and command line if you want to make it completely automated.

Automatization Build Server TFS 2008 (vs 2008)

I use VS 2008, Team Explorer and TFS. I'm looking to automate your builds by executing TFSBuild.exe command.
I follow those steps:
Open TeamExplorer, in VS2008, connected to TFS;
My Team Project has a Build (named MainBuild) in Builds. Then, I do Query New build option.
I fill the properties in window dialog opened:
build Definition: Mainbuild
Build Agent: Machine1BuildAgent
drop folder for this build: \Machine1\Build_drop
priority in queue: Normal
MsBuild command-line arguments:
/p:BuildAll=false /p:RunTest=false /p:SkipClean=true /p:SkipGet=true /p:SkipLabel=true /p:SkipGetChangesetsAndUpdateWorkItems=true
In MDSN I have seen TFSBuild command and this sample:
The following example builds the Nightlies build type which is in the AdventureWorks team project on server01. The resulting build is located on Machine1 in the BuildDrop directory.
TFSBuild start http://server01:8080 AdventureWorks Nightlies /m:Machine1 /d:"C:\BuildDrop"
edit: Now, for my issue, how can I do automation for build MainBuild for set the values for "MsBuild command-line arguments" using TFSBuild.exe command ? I'm looking for a way to automatically have the TFS Build Agent job run nightly with command-line arguments..
I need similar command line like this:
TFSBuild start http://machine01:8080 MyteamProject MainBuild /m:Machine1 /d:"\Machine1\Build_drop" /p:BuildAll=false /p:RunTest=false /p:SkipClean=true /p:SkipGet=true /p:SkipLabel=true /p:SkipGetChangesetsAndUpdateWorkItems=true
I need pass the arguments (MsBuild command-line arguments) to TFSBuild.exe command and automatize the TFS build.
any sample scripting code ?
You can pass MSBuild properties to TFSBuild using the /msBuildArguments switch
TFSBuild start http://machine01:8080 MyteamProject MainBuild /m:Machine1 /d:"\Machine\Build_drop"
/msBuildArguments:"/p:BuildAll=false;/p:RunTest=false;/p:SkipClean=true;
/p:SkipGet=true;/p:SkipLabel=true;/p:SkipGetChangesetsAndUpdateWorkItems=true"
Alternatively, you could also specify these properties in the response file TFSBuild.rsp.
I'm not sure I understand your question clearly, but if you're looking to automate your builds by executing MSBuild from the command-line, you can create a batch file to execute the necessary command using the command-line arguments you want. Then add a scheduled task to 'Scheduled Tasks' in Windows so that this batch file is executed on a regular (e.g. nightly) basis.

TFS Manual Mstest Publish Results?

Following a MSDN web page, I am trying to manually run mstest within my tfsbuild.proj and put the results into the pass/fail logic so the build will fail if this particular test fails. It's kind of like running a FxCop or something else from CMD and capturing a "0" or "1" and force-fail the build.
MSTest /testcontainer:test.dll /publish:http://ourtfsmachine:8080 /teamproject:ProjectName /publishbuild:BuildNumber01 /platform:AnyCpu /flavor:Release
I could understand running this inside an Exec task, butI don't know what the BuildNumber is, for example.
Help?
Instructions for getting the Build Number from http://msdn.microsoft.com/en-us/library/ms243151%28VS.100%29.aspx:
Open Visual Studio and connect to a Team Foundation Server.
Open Team Explorer.
Open your team project and expand the team project node.
Under the build, double-click All Build Types or a specific build type to see its builds. Build names that you can use are in the Name column.