Create custom Bamboo Agent Image Configuration

Bamboo is a great build server and the possibility to use EC2 instances as build agents makes it really cost efficient and flexible. But – most of the time, the stock images provided by Atlassian need to be customized to fit the purpose. But how to do this properly?

The easiest way is to create a new AMI based on the stock images and customize it.

  1. Launch a new instance using on of the existing AMIs (e.g. ami-ed6deb9e for the Ubuntu stock image) or use an instance launched by Bamboo
  2. Connect to it using SSH and customize it.
  3. Open the EC2 management console, select the instance and choose Actions -> Image -> Create Image
  4. Afterwards you need to enter a name and choose Create ImageScreen Shot 2016-05-15 at 20.44.07
  5. Copy the AMI id
  6. Switch back to Bamboo and navigate to Bamboo administration -> Image configurations
  7. Create a new configuration using the AMI id you copied beforeScreen Shot 2016-05-15 at 20.48.37
  8. You can now launch build agents with you custom setup

Grant Access to single S3 bucket

I was setting up a static website on Amazon S3. This process is fairly simply. Finally I wanted to create an user that can only deploy this one single bucket. As with all other user accounts I wanted to follow the least privilege model. So the default S3-Full Access policy was not an option for me.

I created a new policy granting full access to this specific bucket. It looked like this:

{
   "Version": "2012-10-17",
   "Statement": [
   {
     "Effect": "Allow",
     "Action": "s3:*",
     "Resource": [
     "arn:aws:s3:::myBucket/*",
     "arn:aws:s3:::myBucket"]
   }
 ]
}

I assigned this to the user that uploads my site and started the upload. Peng! Access Denied.

After some investigation I discovered that the ListAllMyBuckets action is causing that problem. I added a second policy:

{
   "Version": "2012-10-17",
   "Statement": [
   {
     "Effect": "Allow",
     "Action": "s3:ListAllMyBuckets",
     "Resource": "arn:aws:s3:::*"
   }]
}

This solved my issue and the upload work fine.

error CS0012: The type ‘IEnumerable’ is defined in an assembly that is not referenced.

I was setting up a new build server for a .NET project as I have done several times before. It was a TeamCity build server but that is not important for this problem. When trying to build my solution I got this error:

error CS0012: The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Locally the solution compiled just fine. After some research I found some hints that installing the Targeting Pack for my .NET Framework version solves the problem.

I downloaded and installed the target pack for .NET 4.6 from here. Immediately the problem was solved and the solution compiled without any problems.

It compiled locally because the missing DLL that is installed by the Targeting Pack is also installed by Visual Studio. This is just another reason to think about the “no Visual Studio on the build server” rule.

Powershell OpenFileDialog is not showing up

Recently I was writing scripts that should run on a Windows 7 machine. One task was to select a file and read it. So I used the usual snippet:

$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
[void]$OpenFileDialog.ShowDialog()

I ran the script from PowerShell ISE during development and everything worked fine but when the users executed the script, the file dialog did not open up. Then I came across this page here and it said ShowHelp solves the problem. I changed the script to:

$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.ShowHelp = $true
[void]$OpenFileDialog.ShowDialog()

I am not sure why, but this solved the problem and did not cause any other side effect. I am wondering what ShowHelp actual does because it seems to have no visible effect.

SharePoint stops writing log files

Recently I had a SharePoint installation that stopped writing log files without any clear reason. Restarting the timer service or the whole server did not solve the problem. The only thing I noticed was this entry in the event viewer:

Tracing Service failed to create the trace log file at location specified in SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\WSS\LogDir. Error 0x0: The operation completed successfully. . Traces will be written to the following directory: C:\Users\SVCSPD~3\AppData\Local\Temp\.

Something seemed to be wrong with the log directory but the folder and its permissions looked totally normal. So I opened the Monitoring Settings (Central Admin -> Monitoring -> Configure diagnostic logging), change the path of the trace log to c:\temp and back to its normal location. As soon as I saved the second change, log files started appearing again.

shareoint_monitoring_setting

Android Emulator: Enable keyboard input

Testing android apps with the emulator and not being able to use the normal keyboard to enter text is very annoying and not really efficient. Unfortunately the default device (ATM: Nexus 5) has keyboard input disabled. Enabling it is very easy:

  1. Go to your user’s home directory and search for a folder .android
  2. Open the folder and navigate to the folder avd. You will find one folder for each installed device. Open the folder of the device you are using.
  3. Find the file config.ini and open it in your favourite text editor.
  4. Search for a line starting with hw.keyboard. Change its value to yes. If the line is not present, add the line hw.keyboard=yes

Done. Start the emulator and you will see that the text input is working.