When we queue a build in TFS, if it failed, TFSBuild will create a bug workitem. If it successes, TFSBuild will update associated workitems.
1 How TFSBuild gets associated changesets
private void AnalyzeChangesets(Item[] lastItems, Item[] currentItems);
Declaring Type:
Microsoft.TeamFoundation.Build.Tasks.GenCheckinNotesUpdateWorkItems
Assembly:
Microsoft.TeamFoundation.Build.Tasks.VersionControl, Version=9.0.0.0
As we know, When we queue a build in TFS, TFSBuild will Label the source code, if the Build successes, TFS will record the Label in Database as the LastGoodBuildLabel of the current Build Definition.And the next time we queue the same build definition, TFSBuild can get LastGoodBuildLabel and CurrentLabel.
The task GenCheckinNotesUpdateWorkItems will get lastItems[] in LastGoodBuildLabel and currentItems[] in CurrentLabel.
A If lastItems[i]’s ItemID matches a item in currentItems, like currentItems[j]
Get all changesets between lastItems[i]’s changesetID and currentItems[j]’s changesetID that include this item.
Notice, not all changeset between them include this item
B If lastItems[i]’s ItemID does not match any item in currentItems and does not exist in Latest version
This means that the Item may be deleted in a changeset.Get all changesets between lastItems[i]’s changesetID and VersionSpec.Latest that include this item.
C If currentItems[i]’s ItemID does not match any item in lastItems
Get all changesets between ChangesetVersionSpec(1) and currentItems[i]’s changesetID that include this item.
2 How TFSBuild get associated WorkItems
Each changesets contains a prroperty WorkItems. In the step1 we can get all associated changesets, and then we can get all WorkItems.
3 How associate a WorkItem to changeset
A In Team Explorer, when you check-in a changeset, you can associate workitems to it.
B in Team Explorer, you can edit a changeset and associate workitems to it.
4 How TFSBuild Update WorkItems
TFSBuild will set item["Microsoft.VSTS.Build.IntegrationBuild"] = this.BuildNumber for all associated workitem which have this field.
In TFS2010 Administration Console, you can only set SMTP Server and Email From Address.
And in the TFS Config command line
TFSConfig ConfigureMail /FromEmailAddress:emailAddress /SmtpHost:SMTPHostName
You can not set port. Smtphost:port is not a valid format even though the command could accept it successfully.
In TFS2010, TFSJobAgent is used to send notification. You can edit the TFSJobAgent.exe.config to set the mail port.
Add following script to C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\TFSJobAgent\TfsJobAgent.exe.config
`
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<mailSettings>
<smtp >
<network host="smtpserver" port="26" >
</smtp>
</mailSettings>
</system.net>
</configuration>
The host will be ignored but port will be used.
摘要: Some developers or testers may find that it will be more convenient that they could create a bug in code editor. Select a method, right click and create a work item. Following steps and sample codes i...
阅读全文
This behavior can be done in many ways, Hongye supplied a solution in http://social.msdn.microsoft.com/Forums/en-US/tfsgeneral/thread/c6a4dc3c-39f9-4e37-9de0-93319273b8bc.
Another way is to use the Getting event of VersionControlServer.
1 Create a Visual Studio Add-in project ListenGetStatus
Add following references
EnvDTE
EnvDTE80
EnvDTE90
Microsoft.TeamFoundation
Microsoft.TeamFoundation.Client
Microsoft.TeamFoundation.VersionControl.Client
Microsoft.VisualStudio.TeamFoundation
Microsoft.VisualStudio.TeamFoundation .Client
Microsoft.VisualStudio.TeamFoundation.VersionControl
2 Implement OnStartupComplete
TeamFoundationServerExt tfsExt;
VersionControlExt vsExt;
public void OnStartupComplete(ref Array custom)
{
tfsExt = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;
if (tfsExt.ActiveProjectContext.DomainUri == null)
{
MessageBox.Show("Error");
return;
}
vsExt = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
vsExt.Explorer.Workspace.VersionControlServer.Getting += new GettingEventHandler(VersionControlServer_Getting);
}
static object locker = new object();
void VersionControlServer_Getting(object sender, GettingEventArgs e)
{
lock (locker)
{
FileStream fs = null;
StreamWriter writer=null;
try
{
fs = File.Open("C:\\GettingLog.txt", FileMode.Append);
writer = new StreamWriter(fs);
writer.WriteLine(string.Empty);
writer.WriteLine(DateTime.Now.ToString());
writer.WriteLine(String.Format("ServerItem={0}", e.ServerItem));
writer.WriteLine(String.Format("SourceLocalItem={0}", e.SourceLocalItem));
writer.WriteLine(String.Format("ChangeType={0}", e.ChangeType));
writer.WriteLine(String.Format("DeletionId={0}", e.DeletionId));
writer.WriteLine(String.Format("DiskUpdateAttempted={0}", e.DiskUpdateAttempted));
writer.WriteLine(String.Format("IsDelete={0}", e.IsDelete));
writer.WriteLine(String.Format("IsLatest={0}", e.IsLatest));
writer.WriteLine(String.Format("ItemId={0}", e.ItemId));
writer.WriteLine(String.Format("ItemType={0}", e.ItemType));
writer.WriteLine(String.Format("Status={0}", e.Status));
writer.WriteLine(String.Format("TargetLocalItem={0}", e.TargetLocalItem));
writer.WriteLine(String.Format("Version={0}", e.Version));
writer.WriteLine(String.Format("Workspace={0}", e.Workspace.DisplayName));
}
catch
{
}
finally
{
if (writer != null)
{
writer.Flush();
writer.Close();
}
if (fs != null)
{
fs.Flush();
fs.Close();
}
}
}
}
3 In the above code
if (!e.IsDelete && e.IsLatest), so that the item is a new file and latest.
4 Copy the assembly under bin folder and ListenGetStatus.AddIn to My Documents\Visual Studio 2008\Addins
5 Notice that this needs TeamFoundationServer is available OnStartupComplete, you can use a Timer to check it timely if TeamFoundation is not available.
MSDN has an article about
How to: Configure SMTP Server and E-mail Notification Settings in the Services Web.Config File
1 TFS will use the service account(TFSService) to connect to SmtpServer, so TFSService must be a valid member of your SmtpServer, or your SmtpServer allow anonymous senders to send e-mail.
2 Edit the C:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Web Services\Services\Web.config
<appSettings>
<add key="ConnectionString" value="Data Source=[Server];Initial Catalog=TfsIntegration;Integrated Security=True;Persist Security Info=False;Application Name=TeamFoundation" />
<add key="eventingEnabled" value="true" />
<add key="DetailedExceptions" value="false" />
<add key="emailNotificationFromAddress" value="****@*****.***" />
<add key="smtpServer" value="[smtpHost]" />
<add key="enableEmails" value="true" />
</appSettings>
3 Reset IIS
摘要: For the steps how to create and apply custom control, please refer to How to:Create a Custom WI Control Now we want to a feature to make custom wit control open another work item, like the behavior o...
阅读全文
摘要: First, Thanks for Richard’s blog http://richardsbraindump.blogspot.com/2007/07/versioning-builds-with-tfs-and-msbuild.html A simple way to keep the build number manually is to store last build number ...
阅读全文
摘要: Team Foundation Eventing Service delivers notification of events by e-mail or through Web services. If we subscribe TFS Event using Web Service, we can do much more then E-mail. 1 Create a Asp.NET We...
阅读全文
摘要: After installation of SQL Server Business Intelligence Development Studio(2008), you can create TFS Reports yourself. 1 Using VS to create a Report Server Project “My Reports” 2 Right click Shared Dat...
阅读全文
摘要: The exclude file types are defined in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\SourceControl\AddOptions\ExcludeMasks, the default value like Debug;Release;*.pdb;*.obj;*.dll...
阅读全文