Merge branch 'master' of https://github.com/Swarmops/Swarmops
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SharedLabeller")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SharedLabeller")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("71a8ae4e-af6d-42fd-b62a-96c09044e24a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,133 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Exortech.NetReflector;
|
||||
using ThoughtWorks.CruiseControl.Core;
|
||||
using ThoughtWorks.CruiseControl.Remote;
|
||||
|
||||
// this namespace could be altered and several classes could be put into the same if you'd want to combine several plugins in one dll
|
||||
namespace ccnet.SharedLabeller.CruiseControl.plugin
|
||||
{
|
||||
[ReflectorType("sharedLabeller")]
|
||||
public class SharedLabeller : ILabeller
|
||||
{
|
||||
/// <summary>
|
||||
/// The path where the file that holds the shared label should be located
|
||||
/// </summary>
|
||||
/// <default>none</default>
|
||||
[ReflectorProperty("sharedLabelFilePath", Required = true)]
|
||||
public string SharedLabelFilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Any string to be put in front of all labels. Mutually exclusive with PrefixFile.
|
||||
/// </summary>
|
||||
[ReflectorProperty("prefix", Required = false)]
|
||||
public string Prefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// File with string to be put in front of all labels. Mutually exclusive with Prefix.
|
||||
/// </summary>
|
||||
[ReflectorProperty("prefixFile", Required = false)]
|
||||
public string PrefixFile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the label will be incremented even if the build fails. Otherwise it will only be incremented if the build succeeds.
|
||||
/// </summary>
|
||||
[ReflectorProperty("incrementOnFailure", Required = false)]
|
||||
public bool IncrementOnFailure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If false, the label will never be incremented when this project is builded. This is usefull for deployment builds that
|
||||
/// should use the last successfull of two or more builds
|
||||
/// </summary>
|
||||
[ReflectorProperty("increment", Required = false)]
|
||||
public bool Increment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to set the initial build number.
|
||||
/// This will only be used when on the first build of a project, meaning that when you change this value,
|
||||
/// you'll have to stop the CCNet service and delete the state file.
|
||||
/// </summary>
|
||||
/// <default>0</default>
|
||||
[ReflectorProperty("initialBuildLabel", Required = false)]
|
||||
public int InitialBuildLabel { get; set; }
|
||||
|
||||
public SharedLabeller()
|
||||
{
|
||||
IncrementOnFailure = false;
|
||||
Increment = true;
|
||||
InitialBuildLabel = 768;
|
||||
}
|
||||
|
||||
#region ILabeller Members
|
||||
|
||||
public string Generate(IIntegrationResult integrationResult)
|
||||
{
|
||||
if (ShouldIncrementLabel(integrationResult.LastIntegration))
|
||||
{
|
||||
return Prefix + this.GetLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
return integrationResult.LastIntegration.Label;
|
||||
}
|
||||
}
|
||||
|
||||
public void Run(IIntegrationResult integrationResult)
|
||||
{
|
||||
integrationResult.Label = Generate(integrationResult);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Get and increments the label, unless increment is false then it only gets the label
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetLabel()
|
||||
{
|
||||
ThoughtWorks.CruiseControl.Core.Util.Log.Debug("About to read label prefix file. Filename: {0}", PrefixFile);
|
||||
string prefix = System.IO.File.ReadAllText (PrefixFile).Trim();
|
||||
|
||||
ThoughtWorks.CruiseControl.Core.Util.Log.Debug("About to read build number file. Filename: {0}", SharedLabelFilePath);
|
||||
using (FileStream fileStream = File.Open(this.SharedLabelFilePath,
|
||||
FileMode.OpenOrCreate,
|
||||
FileAccess.ReadWrite,
|
||||
FileShare.None))
|
||||
{
|
||||
// read last build number from file
|
||||
var bytes = new byte[fileStream.Length];
|
||||
fileStream.Read(bytes, 0, bytes.Length);
|
||||
|
||||
string rawBuildNumber = Encoding.UTF8.GetString(bytes);
|
||||
|
||||
// parse last build number
|
||||
int previousBuildNumber;
|
||||
if (!int.TryParse(rawBuildNumber, out previousBuildNumber))
|
||||
{
|
||||
previousBuildNumber = InitialBuildLabel - 1;
|
||||
}
|
||||
|
||||
if (!Increment)
|
||||
{
|
||||
return previousBuildNumber.ToString();
|
||||
}
|
||||
|
||||
int newBuildNumber = previousBuildNumber + 1;
|
||||
|
||||
// increment build number and write back to file
|
||||
bytes = Encoding.UTF8.GetBytes(newBuildNumber.ToString());
|
||||
|
||||
fileStream.Seek(0, SeekOrigin.Begin);
|
||||
fileStream.Write(bytes, 0, bytes.Length);
|
||||
|
||||
return newBuildNumber.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShouldIncrementLabel(IntegrationSummary integrationSummary)
|
||||
{
|
||||
return integrationSummary == null || integrationSummary.Status == IntegrationStatus.Success || IncrementOnFailure;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AE5CF88B-2B4A-4A8B-93C2-2C399E1A0409}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SharedLabeller</RootNamespace>
|
||||
<AssemblyName>ccnet.SharedLabeller.CruiseControl.plugin</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NetReflector">
|
||||
<HintPath>..\NetReflector.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="ThoughtWorks.CruiseControl.Core">
|
||||
<HintPath>..\ThoughtWorks.CruiseControl.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ThoughtWorks.CruiseControl.MSBuild">
|
||||
<HintPath>..\ThoughtWorks.CruiseControl.MSBuild.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ThoughtWorks.CruiseControl.Remote">
|
||||
<HintPath>..\ThoughtWorks.CruiseControl.Remote.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SharedLabeller.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLabeller", "SharedLabeller.csproj", "{AE5CF88B-2B4A-4A8B-93C2-2C399E1A0409}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AE5CF88B-2B4A-4A8B-93C2-2C399E1A0409}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AE5CF88B-2B4A-4A8B-93C2-2C399E1A0409}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AE5CF88B-2B4A-4A8B-93C2-2C399E1A0409}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AE5CF88B-2B4A-4A8B-93C2-2C399E1A0409}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
if not exist C:\Lab\Swarmops\build\Deploy-Staging\BuildDropped.txt goto testSprint
|
||||
if not exist C:\Lab\Swarmops\build\Deploy-Staging\BuildDropped.txt goto testSprint
|
||||
|
||||
|
||||
cd \Lab\Swarmops\build\Deploy-Staging
|
||||
|
||||
|
||||
Reference in New Issue
Block a user