Jenkinsfile for Splunk Forwarder


How to share CCNET label across multiple projects and get incremented for each success build

There is already one post below where I have implemented this but it also increment for failure build also-

How to share CCNET label across multiple projects and get incremented for each build

Now here’s how you can stop it to increment during failure builds-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Exortech.NetReflector;
using ThoughtWorks.CruiseControl.Core;
using ThoughtWorks.CruiseControl.Remote;
namespace ccnet.SharedLabeller.CruiseControl.plugin
    public class SharedLabeller : ILabeller
        /// The path where the file that holds the shared label should be located
        /// none
        [ReflectorProperty(“sharedLabelFilePath”, Required = true)]
        public string SharedLabelFilePath { get; set; }
        /// Any string to be put in front of all labels.
        [ReflectorProperty(“prefix”, Required = false)]
        public string Prefix { get; set; }
        /// If true, the label will be incremented even if the build fails. Otherwise it will only be incremented if the build succeeds.
        [ReflectorProperty(“incrementOnFailure”, Required = false)]
        public bool IncrementOnFailure { get; set; }
        /// 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.
        /// 0
        [ReflectorProperty(“initialBuildLabel”, Required = false)]
        public int InitialBuildLabel { get; set; }
        public SharedLabeller()
            IncrementOnFailure = false;
            InitialBuildLabel = 0;
        #region ILabeller Members
        public string Generate(IIntegrationResult integrationResult)
            if (ShouldIncrementLabel(integrationResult.LastIntegration))
                return Prefix + IncrementLabel();
                return integrationResult.LastIntegration.Label;
        public void Run(IIntegrationResult integrationResult)
            integrationResult.Label = Generate(integrationResult);
        private string IncrementLabel()
            ThoughtWorks.CruiseControl.Core.Util.Log.Debug(“About to read label file. Filename: {0}”, SharedLabelFilePath);
            using (FileStream fileStream = File.Open(this.SharedLabelFilePath,
                // 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;
                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;
This is how you can implement in ccnet.config under project-
         <sharedLabelFilePath>E:\Program Files\CruiseControl.NET\server\buildnumber.txt</sharedLabelFilePath>

How to check if DLL or Assembly is Strong Typed Assembly or Not

Using sn.exe from command prompt, you can verify is DLL is Strong Typed Assembly or not. Example below-
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin>sn.exe -vf C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
For more information on this command, check help by typing- > “sn.exe /?”. In above command, it is mentioned to use -vf for verifying / checking strong name assembly forcefully even if disabled in the registry.Also, you can put below in a script-@ echo off
if “%1″==”” goto END
sn -q -vf %1 > NUL
echo Strongly named assembly: %1
goto END
echo Not a strongly named assembly: %1
goto END