Category Archives: Problems Solved

Using GitVersion in a Jenkins pipeline

After several hours of pain trying to update the build displayName from the GitVersion output I came up with this:


node('windows') {
    stage 'Checkout'
        checkout scm

    stage 'Run GitVersion'
        bat 'git remote remove origin1' // For some reason the pipeline is adding duplicate remotes that GitVersion moans about
        currentBuild.displayName = (bat (script: '@echo off && GitVersion.exe /showvariable FullSemVer', returnStdout: true))

    stage 'Build'
        bat '.\\Build.cmd'
}

Let me know if you think there is a better way! πŸ™‚

EDIT:

So after having a PR get it’s knickers in a twist after I force-pushed a rebased history to a fork of mine (I know, I’m naughty! :)) I came up with this instead. It removes the need to remove the origin1 remote as it pulls directly from the source repo instead of using the local clone:

stage('Run GitVersion') {
	  withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'GitHubCredentials', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
	  	def git_url = bat (script: '@echo off && git remote get-url origin', returnStdout: true)
		currentBuild.displayName = bat (script: "@echo off && GitVersion.exe /showvariable FullSemVer /url ${git_url.trim()} /b ${env.BRANCH_NAME}  /u ${env.GIT_USERNAME} /p ${env.GIT_PASSWORD}", returnStdout: true)
	  }
	}

The credentialsId “GitHubCredentials” is a credential setup in Jenkins, just change to whatever yours is (which may be a guid if you let Jenkins auto-generate one for you).

Connecting to a SqlExpress instance with Wix

The other day I came across a bit of a strange issue when trying to delploy a backup to a fresh SqlExpress 2008 R2 instance. I had setup the Wix Sql database tag using a loopback address:

<sql:SqlDatabase Id="DbNameRef"
                 Database="DbName"
                 Server="127.0.0.1"
                 Instance="SQLEXPRESS"
                 CreateOnInstall="yes"
                 DropOnUninstall="yes"
                 User="MySQLUser"
                 ContinueOnError="yes">

but for some reason it wasn’t connecting at all just erroring with a most helpful error message:

CreateDatabase: Β Error 0x80004005: failed to create SQL database but continuing, error: unknown error, Database: [DATABASE_NAME]

I enabled TCP/IP so that I could use sql profiler and re-ran the installer hey presto guess what it worked! Obviously as SqlExpress only installs with “Shared memory” enabled this was the issue, it couldn’t connect. I tried the sqlcmd method of using “lpc:” as a prefix but still no joy. It turns out that if you cannot use a hostname or ip for the servername to switch over to shared memory’ you have to use “.” as the server name:

<sql:SqlDatabase Id="DbNameRef"
                 Database="DbName"
                 Server="."
                 Instance="SQLEXPRESS"
                 CreateOnInstall="yes"
                 DropOnUninstall="yes"
                 User="MySQLUser"
                 ContinueOnError="yes">

Removing dead library servers and hosts from SCVMM

A while back I was setting up TFS Lab management so that we can start automating a lot of our integration testing. In the process of testing the deployment of the servers and the auto configuration scripts I was creating a lot of temporary virtual servers on the domain and using up IP’s on the network before they could be released. Therefore I wasn’t too popular with the OP’s guys and they decided to put the lab server in it’s own domain.

Unfortunately this caused a few issues as it meant that the SCVMM backed could not contact the hosts and the library servers as they had moved domain. Removing the hosts was a simple matter of dropping to PowerShell (There is a handy button at the top of the SCVMM Admin console) and running the following command:

Remove-VMHost "[SERVER_FQDN]" -Force

However the PowerShell command for removing dead library servers is not so helpful as it doesn’t have a “Force” flag and it comes up with an error saying it can’t be contacted:

Error (406) - Access has been denied while contacting the server

Luckily as the SCVMM backend is controlled by Sql server it wasn’t too difficult to find where the definitions of the library server were stored. Just connect to the SCVMM database instance ([YOUR_SCVMM_SERVER]\MICROSOFT$VMM$) and the table you need to look at is the tbl_ADHC_Library table. Firstly do a select on the table to get the GUID/UNIQUEIDENTIFIER of the library server(s) you need to delete:

use VirtualManagerDB
go

select
    LibraryID,
    ComputerName
from dbo.tbl_ADHC_Library

From this query take the LibraryID field and for each of the library servers you need removing, run the following command:

use VirtualManagerDB
go

exec prc_ADHC_Library_Delete '[LibraryID]'

Hey presto all the dead servers are now gone!

As always please make sure you have a backup and don’t blame me if you break your SCVMM server!!

A few “features” in MSBuild that caused me pain today…

Today I decided to work on deploying to both our internal load-balanced app servers directly from a manually run build. Unfortunately I came across the following issues that caused me to spend far too long on this task!!

Currently I have a library of MSBuild .targets files that load in generic tasks that I can run after a build has run. One of them is a DeployWebsite task that uses a couple of Properties and can clean down and deploy the latest code from the build. I realised that all I needed to do was modify the current build to set the deploy location first. However this turned out to be a lot harder than I thought it would be…

Firstly I tried the following code which doesn’t set the Global property “AppFolderPath”:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <AppFolderPath>[INVALID]</AppFolderPath>
    </PropertyGroup>
    <Target Name="SetDeployLocation">
        <PropertyGroup>
            <AppFolderPath>[SOME SHARE ON SERVER]</AppFolderPath>
        </PropertyGroup>
        <CallTarget Targets="DeployWebsite" />
    </Target>
    <Target Name="DeployWebsite">
        <Message Text="AppFolderPath=$(AppFolderPath)" />
    </Target>
</Project>

To fix this you need to seperate the tasks into two Targets and call them from a single parent Target and set the Property using CreateProperty (not declaratively and doesn’t matter if you have already created it!):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <AppFolderPath>[INVALID SHARE]</AppFolderPath>
    </PropertyGroup>
    <Target Name="DeployToLive">
        <CallTarget Targets="SetDeployLocation" />
        <CallTarget Targets="DeployWebsite" />
    </Target>
    <Target Name="SetDeployLocation">
        <CreateProperty Value="[SOME SHARE ON SERVER]">
            <Output TaskParameter="Value" PropertyName="AppFolderPath" />
        </CreateProperty>
    </Target>
    <Target Name="DeployWebsite">
        <Message Text="AppFolderPath=$(AppFolderPath)" />
    </Target>
</Project>

Once I’d fixed those it still wouldn’t call the DeployWebsite multiple times. The first worked fine, however it turns out that MSBuild will not allow you to call a target with the same name twice. To get around this you can spawn a separate MSBuild task for each instance you need to run:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="DeployWebsiteToLive">
        <MSBuild Targets="DeployWebsite"
            Properties="AppFolderPath=[SHARE ON SERVER 1];BuildDirectory=$(BuildDirectory)"
            Projects="$(MSBuildProjectFile)" />

        <MSBuild Targets="DeployWebsite"
            Properties="AppFolderPath=[SHARE ON SERVER 2];BuildDirectory=$(BuildDirectory)"
            Projects="$(MSBuildProjectFile)" />
    </Target>
    <Target Name="DeployWebsite">
        <Message Text="AppFolderPath=$(AppFolderPath)" />
    </Target>
</Project>

One thing to notice there is you need to pass across ALL properties that are not set declaratively. If you do not pass anything these are all sent across automatically, but MSBuild still detects that the two tasks are exactly the same and only runs the first one.

Hopefully you won’t have to spend as long as I did on it now! πŸ™‚

VDPAU stops working after you upgrade the NVIDIA drivers on debian based distros

The last week or so I’ve been having issues with the NVIDIA drivers on my Acer Apsire Revo and had to reinstall them several times (due to a failed update of the new DKMS package breaking everything). I took the opportunity to also upgrade them to the latest version. Eventually after lots of playing around I got them to work again but my 720p videos weren’t behaving. After a bit of digging I found the vdpauinfo tool and got the following message:

“Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory”

This seemed a bit strange as I knew it was installed as I distinctly remember doing it. A bit more digging turns out that the previous installers add a symlink which what apps use instead [ref]. So it was a simple matter of adding it back in with the flowing command:

1
sudo ln -s /usr/lib/vdpau/libvdpau_nvidia.so.1 /usr/lib/libvdpau_nvidia.so

Hey presto everything was back to normal and the HD gods were smiling down on me! πŸ™‚

Team build fails even though the project builds fine.

The last few days we’ve been having a strange problem where TeamBuild on our TFS server was repeatedly failing. What was even weirder was that the solution definitely builds OK and there are no compile errors. So I started digging around in the log file and as you will no doubt know (On average mine are 3k-10k line plain text files!!) this is a rather painful task.

After quite a while looking through this it was a fruitless exercise and was no closer to find out why. Luckily I have already setup other VM build servers and these were running ok so was able to narrow it down to the TFS server itself. Next I tried deleting the BuildSources folder to see if there was any rouge or corrupt files there. Nope, not that. I vaguely seemed to remember that the Build process itself runs as a windows service so I checked that out. Was seemingly working fine but decided to give it a bounce just incase. AS always this action seems to work and the build server started working fine. I just wish I’d always remember to log-out/restart app/reboot first as this would have saved a LOT of time.

Just remember when 1st-line tell you to log-out/reboot, do it, you might be surprised!! πŸ™‚

Using the virtual memory restriction in IIS6

We’ve been having some seemingly random performance issues on some of sites and for a while I was quite stumped. Basically every so often the website would take between 16-20 seconds to load the page, although we were not able to predict when it would happen, as it occurred on different pages within the site.

My initial thought was that it was a network issue due to the fact that it was only being reported on some sites. Luckily the company subscribes to a external monitoring service so I was able to see the sites that it was happening on and how frequently. Once I had a look there I noticed that was happening on all the sites to varying degrees.

One of the servers was taken out of the DMZ to try and isolate the issue and it was only then that I noticed what was going on. With all the other sites shut down and only one or two w3wp.exe process to keep an eye on I was noticing that one of the processes was being shutdown and replaced with a new one. Now I know that this is the what happens when an app pool gets recycled but this shouldn’t have been happening as we had only 1 scenario enabled, the virtual memory limit setting:

ο»Ώο»Ώ

As you can see this was set to 250Mb and process itself was never getting anywhere near that!! In fact even before I had thought it was a network problem I did actually check for this, however with so many w3wp.exe processes (~30) it was difficult to see them recycling, and because none of them were going near my limit I quick discounted this idea! So I went ahead and removed the setting and re-ran the tests. Low and behold it fixed the issue. Now the reason I had set it in the first place was due to getting System.OutOfMemory exceptions if too many bots were walking the site at one time. This happens due to the fact that we use the XsltCompiledTransform to clean up content coming from our Homebrew CMS. This generates a lot of assemblies and hence when to much content is accessed too quickly it runs out of memory. Initially I was wondering if there was a bug in IIS6 but it turns out that memory can be consumed directly from the swap disk completely bypassing the physical RAM and hence why the w3wp.exe never got anywhere near my limit.

Anyway in the end the fix was quite simple, just use the physical memory setting in IIS. πŸ™‚

64-bit W360BT Bluetooth drivers for a Dell D630 laptop

After re-installing my work laptop with the 64-bit trial of Windows Server 2008 I was having trouble getting the bluetooth working due to a lack of drivers. Strangely Dell do not list any compatible drivers when you use the service code however after much googling (and people suggesting using Toshiba drivers which didn’t seem to work) I managed to find some, you’ll never guess where, yes the Dell website!!

The drivers can be found here.

They seem to be working so far even though the GUI comes up with an incompatible OS warning (and I use a Bluetooth mouse!).

Make sure you uninstall obsolete hardware apps when P2V’ing servers!!

The last few days I have been performance testing one of our websites due to a severe performance drop after migrating to a new VMware hosted environment. Admittedly the application is not a great perfomer anyway (due to IMHO major overspeccing on the application security) but there was a significant drop in performance that was causing users (and us) grief.

It turned out that IBM director was using about a constant 30% CPU whilst the box was doing anything and even though it never actually reached 100% the user experience was that of a box under full load. Once it was disabled/uninstalled the box went back to normal.

TBH this was prob an oversight on the person doing the P2V but uninstalling obsolete software is something that really should be done as a matter of course!!

Orcale Enterprise Linux hangs when booting under VirtualBox

Wow, 2 posts in one day this is a new record for me! πŸ™‚

One of my tasks on ATM is to do som PoC work on Oracle WebCenter. Unfortunately the VM supplied by the vendor was corrupted so I have downloaded the ISO’s myself and giving it a go setting up in VirtualBox. I much prefer VirtualBox over VMWare Server or Hyper-V (As with all MS software V3 will be the one!! ;)) but was having problems getting the Enterprise Linux ISO to boot and was hanging here:

Oracle Enterprise on VirtualBox hanging screen

However just a few tweaks of the settings were required to get it to boot to the installation screens. The setting that need enabling was the “Enable IO APIC” setting:

VirtualBox setting required