Wednesday, June 08, 2016

Get parameter and enviornment variable in Jenkins 2.0 pipeline job's Groovy script

In order to get Pipeline job parameter (defined by user) in the Groovy script I used following

${ENV:environment}

while to get enviornment variables to the Pipeline job I used following

$env.BUILD_NUMBER

Friday, June 03, 2016

Allow HTML report containing inline scripts and styles in Jenkins

In Order Jenkins to display HTML reports which uses JS and CSS, I executed following command from Manage Jenkins => Scripe Console

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-scripts allow-same-origin; default-src 'self'; script-src 'self' 'unsafe-inline'; img-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';")

Thursday, March 03, 2016

Find all NUnit test assemblies recursively and run them using PowerShell

In order to grab all unit tests assemblies recursively within folder and run them using NUnit I used following PowerShell script. Here I am filtering assemblies found in obj folder.

$nunit = "C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console.exe"
$assemblies = ""
$items = Get-ChildItem  -Path .\Test  -Filter *UnitTests.dll -Recurse | Where {$_.FullName -notlike "*\obj\*"} 

foreach ($item in $items)
{
$assemblies = $assemblies + " " + $item.FullName  
}

$nunitcmd = """C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console.exe"" $assemblies /nologo /xml=c:\dump.xml"
$nunitcmd
cmd /c $nunitcmd

Tuesday, February 09, 2016

Execute MS SQL commands from PowerShell

In order to execute MS SQL commands from PowerShell I used following script.

$sqlquery=@"
USE [DBName]
GO
select * from table
"@

Invoke-Sqlcmd -ServerInstance "ServerName" -Query $sqlquery -Verbose

Thursday, October 08, 2015

Get Substring from nAnt property

In order to get sub-string of the nAnt property, to be used in xmlpoke for nAnt I used following statement. Besides the sub-string the following statement also returns the upper case of the string. Here GIT.Commit is the nAnt property.

<xmlpoke file="my.config" xpath="//UI//application//@version" value="${Version}.${string::substring(string::to-upper(GIT.Commit),0,5)}" />

Wednesday, September 30, 2015

Exit Jenkins

In order to shutdown Jenkins and all ports associated with it's process on server I used following URL

http://jenkins-server-url/exit

Thursday, September 03, 2015

C:\Progra~2 for C:\Program Files (x86)

Dont want to use  in your tools because there is space between Program and Files. Then use C:\Progra~2 which maps to C:\Program Files (x86). And yes if you use C:\Progra~1 it maps to C:\Program Files

Thursday, July 09, 2015

Get date, add minutes and format it in PowerShell

In order to get current date and add minutes to it and format it I used following command in PowerShell

(get-date).AddMinutes(10).ToString("dd/MMMM/yyyy HH:mm")

Thursday, March 27, 2014

Set control's colour pragmatically in C#

In order to set control's colour pragmatically, I used following syntax in C#

btnSearch.ForeColor = Color.FromArgb(0x444444);

Thursday, February 27, 2014

Check for string if it contains positive integer in C#

In order to check if strings is positive integer I used following check in C#

        String maxRecords;

        if (maxRecords == "" || !maxRecords.All(Char.IsDigit))
        {
               // Logic to implement when string contains no valid postive integer.
        }

Monday, February 24, 2014

Wrap text for the particular column of GridView

In order to wrap particular column of GridView of ASP.NET I used following

    protected void GridViewLog_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[7].Attributes.Add("style", "word-break:break-all;word-wrap:normal");
    }

Here column 7 of the GridView gets text wrapped.

Wednesday, February 12, 2014

Close Browser using C#

In Order to Kill (close) all Internet Explorer browser launched, I used following C# code

            Process[] localByName = Process.GetProcessesByName("iexplore");

            foreach (Process item in localByName)
            {
                try
                {
                    item.Kill();
                }
                catch
                {

                }
            }

Tuesday, February 11, 2014

CruiseControl Scheduled Trigger

In order to schedule CruiseControl build at specific time every day, I used following trigger in the project block

<triggers>
<scheduleTrigger time="22:00" buildCondition="ForceBuild" />
    </triggers>

Start and Stop IIS Website using PowerShell

In Order to stop and start website using PowerShell script I used following command

Import-Module WebAdministration

Stop-WebSite -Name 'Maintenance'

Start-Sleep -s 5

Start-WebSite -Name 'Maintenance'

Wednesday, February 05, 2014

Show stack trace in NUnit report in CruiseControl Dashboard

In order to have stack train in CruiseControl NUnit webdashboard report, I have added <xsl:value-of select="./failure/stack-trace"/> in webdashboard\xsl\nunitv2.xsl file. Here is the snippet

        <xsl:if test="@success != 'True' ">
      <tr bgcolor="#FF9900"><td colspan="3"><xsl:value-of select="./failure/message"/><br></br><br></br><xsl:value-of select="./failure/stack-trace"/></td></tr>
</xsl:if>

Monday, December 09, 2013

Using extra & with XMLPoke of nAnt

When using XMLPoke on nAnt I used extra amp; when String already contains &amp;

For example

<xmlpoke file="Menu.xml" xpath="//Item[Name[text()='ams']]//ArgumentExpression" value="https://www.myserver.com/Home.aspx?TID={session}&amp;cid={cid}&amp;Username={username}&amp;uiculture={uiculture}" />

I used following extra &amp; as shown below and XMLPoke worked.

<xmlpoke file="Menu.xml" xpath="//Item[Name[text()='ams']]//ArgumentExpression" value="https://www.myserver.com/Home.aspx?TID={session}&amp;amp;cid={cid}&amp;amp;Username={username}&amp;amp;uiculture={uiculture}" />
 

Wednesday, November 20, 2013

Get Installed .NET versions list

In order to know which .NET frameworks being installed, use following command from the Comand Promt

wmic product where "Name like 'Microsoft .Net%'" get Name, Version

Wednesday, August 07, 2013

Get Multiple Services using Single PowerShell Command

In order to get multiple services using single PowerShell command I used following

Get-Service | Where-Object {($_.name -like "FV*") -or ($_.name -like "QESE*")}

Wednesday, December 12, 2012

Clean Redis DB

In order to clean redis database, I used following commnad

redis-cli -p 1216

redis-cli> flushall

Delete all Objects (Images) from Excel Workbook

Select the workbook
Press F5
Click Special
Select Objects
Click OK
Press Delete key from Keyboard