Skip to content
This repository was archived by the owner on Feb 12, 2019. It is now read-only.

Added support for copy configuration #91

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -10,4 +10,5 @@ output
*.TeamCitySharp.sln.metaproj*
*.DotSettings.*
nuget
Package
Package
/TeamCitySharp.sln.ide
6 changes: 6 additions & 0 deletions src/TeamCitySharp/ActionTypes/BuildConfigs.cs
Original file line number Diff line number Diff line change
@@ -209,5 +209,11 @@ public BuildConfig BuildType(BuildTypeLocator locator)

return build;
}

public string CopyConfiguration(BuildTypeLocator projectLocator, BuildTypeLocator locatorToCopy, string newName)
{
_caller.PostFormat(string.Format("<newBuildTypeDescription name='{0}' sourceBuildTypeLocator='{1}' copyAllAssociatedSettings='true' shareVCSRoots='false'/>", newName, locatorToCopy), HttpContentTypes.ApplicationXml, "/app/rest/projects/{0}/buildTypes", projectLocator);
return ByConfigurationName(newName).Id;
}
}
}
2 changes: 2 additions & 0 deletions src/TeamCitySharp/ActionTypes/IBuildConfigs.cs
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ public interface IBuildConfigs
void DeleteParameter(BuildTypeLocator locator, string parameterName);
void DeleteBuildTrigger(BuildTypeLocator locator, string buildTriggerId);

string CopyConfiguration(BuildTypeLocator locatorToCopy, BuildTypeLocator locator, string newName);

/// <summary>
/// Makes a build type inherit a template.
/// </summary>
19 changes: 18 additions & 1 deletion src/TeamCitySharp/DomainEntities/AgentRequirements.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Web;

namespace TeamCitySharp.DomainEntities
{
@@ -9,6 +10,22 @@ public override string ToString()
return "agent-requirements";
}

public List<AgentRequirement> AgentRequirement { get; set; }
public List<AgentRequirement> AgentRequirement { get; set; }

public string GetAsXml()
{
if (AgentRequirement == null)
return "<agent-requirements/>";
string result = string.Empty;
result += "<agent-requirements>";
foreach (var item in AgentRequirement)
{
result += "<agent_requirement id=\"" + item.Id + "\" type=\"" + item.Type + "\">";
result += item.Properties.GetAsXml();
result += "</agent_requirement>";
}
result += "</agent-requirements>";
return result;
}
}
}
17 changes: 17 additions & 0 deletions src/TeamCitySharp/DomainEntities/ArtifactDependencies.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Web;

namespace TeamCitySharp.DomainEntities
{
@@ -10,5 +11,21 @@ public override string ToString()
}

public List<ArtifactDependency> ArtifactDependency { get; set; }

public string GetAsXml()
{
if (ArtifactDependency == null)
return "<artifact-dependencies/>";
string result = string.Empty;
result += "<artifact-dependencies count=\"" + ArtifactDependency.Count + "\">";
foreach (var item in ArtifactDependency)
{
result += "<artifact-dependency id=\"" + item.Id + "\" type=\"" + item.Type + "\">";
result += item.Properties.GetAsXml();
result += "</artifact-dependency>";
}
result += "</artifact-dependencies>";
return result;
}
}
}
38 changes: 19 additions & 19 deletions src/TeamCitySharp/DomainEntities/BuildConfig.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
namespace TeamCitySharp.DomainEntities
{
public class BuildConfig
{
public override string ToString()
{
return Name;
}

public string Id { get; set; }
public string Name { get; set; }
public string Href { get; set; }
public string ProjectId { get; set; }
public string ProjectName { get; set; }
public string Description { get; set; }
public string WebUrl { get; set; }

namespace TeamCitySharp.DomainEntities
{
public class BuildConfig
{
public override string ToString()
{
return Name;
}
public string Id { get; set; }
public string Name { get; set; }
public string Href { get; set; }
public string ProjectId { get; set; }
public string ProjectName { get; set; }
public string Description { get; set; }
public string WebUrl { get; set; }
public Project Project { get; set; }

public Parameters Parameters { get; set; }
@@ -23,7 +23,7 @@ public override string ToString()
public VcsRootEntries VcsRootEntries { get; set; }
public BuildSteps Steps { get; set; }
public AgentRequirements AgentRequirements { get; set; }
public BuildTriggers Triggers { get; set; }
public Properties Settings { get; set; }
public BuildTriggers Triggers { get; set; }
public Properties Settings { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/TeamCitySharp/DomainEntities/BuildSteps.cs
Original file line number Diff line number Diff line change
@@ -10,5 +10,21 @@ public override string ToString()
}

public List<BuildStep> Step { get; set; }

public string GetAsXml()
{
if (Step == null)
return "<steps/>";
string result = string.Empty;
result += "<steps count=\"" + Step.Count + "\">";
foreach (var item in Step)
{
result += "<step id=\"" + item.Id + "\" name=\"" + item.Name + "\" type=\"" + item.Type + "\">";
result += item.Properties.GetAsXml();
result += "</step>";
}
result += "</steps>";
return result;
}
}
}
16 changes: 16 additions & 0 deletions src/TeamCitySharp/DomainEntities/BuildTriggers.cs
Original file line number Diff line number Diff line change
@@ -10,5 +10,21 @@ public override string ToString()
}

public List<BuildTrigger> Trigger { get; set; }

public string GetAsXml()
{
if (Trigger == null)
return "<triggers/>";
string result = string.Empty;
result += "<triggers count=\"" + Trigger.Count + "\">";
foreach (var item in Trigger)
{
result += "<trigger id=\"" + item.Id + "\" type=\"" + item.Type + "\">";
result += item.Properties.GetAsXml();
result += "</trigger>";
}
result += "</triggers>";
return result;
}
}
}
15 changes: 15 additions & 0 deletions src/TeamCitySharp/DomainEntities/Properties.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Web;

namespace TeamCitySharp.DomainEntities
{
@@ -9,5 +10,19 @@ public override string ToString()
return "properties";
}
public List<Property> Property { get; set; }

public string GetAsXml()
{
if (Property == null)
return "<properties/>";
string result = string.Empty;
result += "<properties>";
foreach (var property in Property)
{
result += "<property name=\"" + HttpUtility.HtmlEncode(property.Name) + "\" value=\"" + HttpUtility.HtmlEncode(property.Value) + "\"/>";
}
result += "</properties>";
return result;
}
}
}
18 changes: 17 additions & 1 deletion src/TeamCitySharp/DomainEntities/SnapshotDependencies.cs
Original file line number Diff line number Diff line change
@@ -10,5 +10,21 @@ public override string ToString()
}

public List<SnapshotDependency> SnapshotDependency { get; set; }
}

public string GetAsXml()
{
if (SnapshotDependency == null)
return "<snapshot-dependencies/>";
string result = string.Empty;
result += "<snapshot-dependencies count=\"" + SnapshotDependency.Count + "\">";
foreach (var item in SnapshotDependency)
{
result += "<snapshot-dependency id=\"" + item.Id + "\">";
result += item.Properties.GetAsXml();
result += "</snapshot-dependency>";
}
result += "</snapshot-dependencies>";
return result;
}
}
}
17 changes: 17 additions & 0 deletions src/TeamCitySharp/DomainEntities/VcsRootEntries.cs
Original file line number Diff line number Diff line change
@@ -10,5 +10,22 @@ public override string ToString()
}

public List<VcsRootEntry> VcsRootEntry { get; set; }

public string GetAsXml()
{
if (VcsRootEntry == null)
return "<vcs-root-entries/>";
string result = string.Empty;
result += "<vcs-root-entries count=\"" + VcsRootEntry.Count + "\">";
foreach (var item in VcsRootEntry)
{
result += "<vcs-root-entry>";
result += "<vcs-root-entry id=\"" + item.VcsRoot.Id + "\" name=\"" + item.VcsRoot.Name + "\" href=\"" + item.VcsRoot.Href + "\">";
result += "<checkout-rules/>";
result += "</vcs-root-entry>";
}
result += "</vcs-root-entries>";
return result;
}
}
}
6 changes: 3 additions & 3 deletions src/TeamCitySharp/ITeamCityClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TeamCitySharp.ActionTypes;
using TeamCitySharp.ActionTypes;

namespace TeamCitySharp
{
@@ -7,7 +7,7 @@ public interface ITeamCityClient
void Connect(string userName, string password);
void ConnectAsGuest();
bool Authenticate();

IBuilds Builds { get; }
IBuildConfigs BuildConfigs { get; }
IProjects Projects { get; }
@@ -16,6 +16,6 @@ public interface ITeamCityClient
IAgents Agents { get; }
IVcsRoots VcsRoots { get; }
IChanges Changes { get; }
IBuildArtifacts Artifacts { get; }
IBuildArtifacts Artifacts { get; }
}
}
16 changes: 8 additions & 8 deletions src/TeamCitySharp/TeamCityClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TeamCitySharp.ActionTypes;
using TeamCitySharp.ActionTypes;
using TeamCitySharp.Connection;

namespace TeamCitySharp
@@ -37,8 +37,8 @@ public bool Authenticate()
}

public IBuilds Builds
{
get { return _builds ?? (_builds = new Builds(_caller)); }
{
get { return _builds ?? (_builds = new Builds(_caller)); }
}

public IBuildConfigs BuildConfigs
@@ -55,8 +55,8 @@ public IServerInformation ServerInformation
{
get { return _serverInformation ?? (_serverInformation = new ServerInformation(_caller)); }
}

public IUsers Users
public IUsers Users
{
get { return _users ?? (_users = new Users(_caller)); }
}
@@ -72,13 +72,13 @@ public IVcsRoots VcsRoots
}

public IChanges Changes
{
get { return _changes ?? (_changes = new Changes(_caller)); }
{
get { return _changes ?? (_changes = new Changes(_caller)); }
}

public IBuildArtifacts Artifacts
{
get { return _artifacts ?? (_artifacts = new BuildArtifacts(_caller)); }
}
}
}
}
1 change: 1 addition & 0 deletions src/TeamCitySharp/TeamCitySharp.csproj
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />