How do you pull code based on a build label from Team Foundation Server in CruiseControl.NET.
<sourcecontrol type="vsts" autoGetSource="true" applyLabel="true">
<server>http://tfs.internal.com:8080/</server>
<username>*********</username>
<password>*********</password>
<domain>corp</domain>
<project>$/Code</project>
<workingDirectory>D:\BuildServer\Lane1\SourceCode\</workingDirectory>
<cleanCopy>false</cleanCopy>
</sourcecontrol>
According to the documentation for CruiseControl.NET TFS plugin (from codeplex):
<sourcecontrol type="vsts" autoGetSource="true" applyLabel="true">
<server>http://my_team_foundation_server:8080</server>
<username>my_user</username>
<password>my_password</password>
<domain>my_domain</domain>
<project>$/Foobar</project>
<workingDirectory>c:\projects\Foobar</workingDirectory>
<cleanCopy>false</cleanCopy>
<workspace>my_workspace_name</workspace>
<deleteWorkspace>false</deleteWorkspace>
</sourcecontrol>
I do not see this as an option.
I did look at the general TFS sourcecontrol block documentation here and you may be able to use as a way to passing the label as a parameter to the executable. I have not ever tried that with Visual Studio but maybe you can figure out what if you can use dynamicValues as a parameter for specifying your label against the compiler. If not, I do not think CruiseControl.NET can support these TFS features.
Related
I developed automated tests in Java. The XML test report is generated with junit 5 and xray-junit-extension. This XML is currently being integrated in Jira/Xray, but unfortunately the labels are not being added to the issue.
I believe that the labels could be integrated in two different ways, 1) through this XML test report, or, alternatively, 2) through the Jenkins pipeline itself.
My XML contains the following property :
Click here to see the screenshot
Similarly to what is written in the Xray documentation :
Click in order to see the screenshot of the documentation
https://docs.getxray.app/display/XRAY/Taking+advantage+of+JU...
The only difference is that in the Xray documentation there is a wrap around the tags property. In my XML I do not have that wrap.
Do you happen to have any idea on why the label is not being added in Jira/Xray?
The second approach would be using the XrayImportBuilder to add a label, using importInfo
step([$class: 'XrayImportBuilder',
endpointName: '/junit',
importFilePath: '/reports/.xml',
projectKey: 'P34AMA',
importToSameExecution: 'false',
//testExecKey: 'TSTLKS-753',
serverInstance: '3146a388-d399-4e55-ae28-8c65404d6f9d',
credentialId:'55287529-194d-4e91-9964-7d740d8d2f61',
importInfo: "{ "fields": {"labels": ["label"]}",
//importInfo = '{"fields": {"labels": ["EOD"]} }'
])
Problem using XrayImportBuilder in Jenkins
But when adding importInfo to my pipeline it ends with an issue :
Click here to see the Jenkins logs
Clcik here to see the Jenkins Import Step
Is anyone aware of any other way to add a label to jira automatically without using the hudson.plugins.jira.JiraIssueUpdater ?
Thank you very much for your help!
Environment
TFS2013.Update 2 12.0.30324.0
C#
Visual Studio 2013
Visual Studio Test Runner
Gated Check-In
Problem
As shown here I decorated my TestMethod like
[TestCategory("Gated"), TestMethod()]
As shown here I filtered, like
TestCategory=Gated
When I build without any filter, the TestRun run successfully with all unit tests. But when I tried to filter over TestCaterory, no TestRun started at all.
I tried without success ...
... to put the filter in quotation:
"TestCategory=Gated"
... to separate the attributes:
[TestMethod]
[TestCategory("Gated")]
... a similar question has been posted here, but I can't revert back to using the old default.xaml.
... I found just one warning in the build log under "Run Visual Studio Test Runner for Test Sources": "Dependent Assembly Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed of C:\Builds2\56\614\bin\External\Microsoft.TeamFoundation.TestManagement.Common.dll not found. Can be ignored if not a NUnit project."
-> I added the reference to Newtonsoft.Json in every single NUnit-Project in all the solutions, that were build during the gated check-in - also without success.
The problem was not the TestCategory, but another pretty simple one:
The unittest-project in which the “broken” testmethod resides was not part of ”projects to Build” of the Build Definition.
We are trying to have ReSharper's cleanup code run on TFS Checkin. Ideally, when you right click on the solution / project and select Source Control > Check in all the files in the "Included Changes" should run cleanup code. I've got the custom checkin policy to work to some extent, works fine if you select a single file to check in but when you select the solution or project, it tries to run cleanup code on the entire solution / project and not just the files selected in TFS Pending Changes "Include Changes".
I'm running VS 2013 with R# 8.2. My policy evaluate code:
public override PolicyFailure[] Evaluate()
{
if (PendingCheckin.Policies.EvaluationState == PolicyEvaluationState.Unevaluated)
{
DTE2 dte = PendingCheckin.GetService(typeof (DTE)) as DTE2;
foreach (EnvDTE.Document doc in dte.Documents)
{
doc.DTE.ExecuteCommand("ReSharper_SilentCleanupCode");
}
}
return new PolicyFailure[0];
}
I don't think this only applies to ReSharper, executing "Edit.FormatDocument" here would most likely run on all files as well.
Is there a way to run ExecuteCommand on only 1 file / document?
It seems like
PendingCheckin.GetService(typeof (DTE))
only gets files that are open in the Visual Studio editor not all the files that are in the "Include Changes" list. I can get a list of PendingChange through
PendingCheckin.PendingChanges.CheckedPendingChanges
But I don't know how to execute a command on PendingChange. Recommendations here would help
PS: I've read that the check in policy is meant to be used for checking documents only, however this workflow is what we need.
I am trying to setup alerts to the team when a specific file is checked into TFS, have have found some info on this using tfs 2008, which leads me to believe the following filter should work:
'Artifacts/Artifact[starts-with(#ServerItem, $/Matrix/Dev/Matrix/Applications/Matrix.UI/Web.Config)]' <> NULL
But this just give me an Invalid Token error, any ideas how i get this working in 2010?
Thanks.
With installed Power Tools, right-click in Team Explorer on the upmost node (the icon for the TeamCollection) & open "Alerts Explorer".Generate a new CheckIn alert:
now set the source control pathto the files you 're interested in:
This generated a Filter Expression = 'Artifacts/Artifact[starts-with(translate(#ServerItem, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "$/foo/bar.cs")]' <> null
In order to retrieve the information which Changeset was included in which Build, we use "Label Sidekick" of Team Foundation Sidekicks, where we place the Label of the Build & expect to find the newly built Changeset.
Our development process in TFS 2010 is making use of 'Gated' checkins, so we are faced with the situation that the latest checkins are not presented in Sidekicks (we actually receive the changeset of the previous build). This is explainable, since at the time the labeling takes place, the latest changes have not yet been committed.
The BuildLog does report the associated Changeset correctly.
I 've made several experiments in our Build Process Template but can't seem to get what we need.
Placing, for example, the Labeling activity out of the "Run On Agent" scope, lead me to a build that fails at the very start with an "Object reference not set to an instance of an object." (I suppose this is related with fact I had to widen the scope for 'Label' & 'Workspace' variables to get the second part running).
The 'before' state of the build process template for this attempt is here (this works), the 'after' state ("Object ref not set..") is here.
So, to summarize, two different types of input could help me out:
How should I change our build process template so that the labeling happens after the Gated checkins have been committed? (-- This would rationalize the display in Sidekicks)
or
How can I programmatically retrieve the associated Changeset of each Build? (-- This would enable me to write a small app that could obsolete the Sidekicks angle)
You can use the TFS API to get this done.
public static void GetBuild()
{
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfsdevlonuk:8080/tfs/gazprom.mt"), new UICredentialsProvider());
tfs.EnsureAuthenticated();
var buildServer = tfs.GetService<IBuildServer>();
// Get Project Name
var versionControl = tfs.GetService<VersionControlServer>();
var teamProjects = versionControl.GetAllTeamProjects(true);
// Get Builds for a team project
var buildDetails = buildServer.QueryBuilds(teamProjects[0].Name);
// For each build
foreach (IBuildDetail buildDetail in buildDetails)
{
// Get the build details
var buildInfor = buildDetail.Information;
// More build infor like shelveset, etc
Debug.Write(buildDetail.LabelName + buildDetail.ShelvesetName);
}
The above code will help you get the build details programatically. I have some blog posts on how to connect to tfs programmatically and use the tfs api. http://geekswithblogs.net/TarunArora/archive/2011/06/18/tfs-2010-sdk-connecting-to-tfs-2010-programmaticallyndashpart-1.aspx