Set up and run your first Bamboo job

This guide is part five of ‘How to set up Continuous Integration for Salesforce.com‘, and will take you through how to set up Atlassian Bamboo to execute Salesforce deployments on a codebase made available in Atlassian Stash.

In the previous article we added the deployment dependencies to the Bamboo server. By the end of this post we will have deployed this new feature to another Salesforce instance using Atlassian Bamboo.

Pre-requisites

This tutorial assumes that you  have the pre-requisites available from the parent article – ‘Setting up Continuous Integration for Salesforce.com‘, and have carried out the below steps of this walkthrough:

  1. Setting up Eclipse, and making your first commit to Stash;
  2. Commit your Salesforce.com codebase to Stash;
  3. Developing new features and committing them to Stash;
  4. Setting up the pre-requisites for Bamboo to execute Salesforce deployments.

Also, ensure that your Admin has linked your Bamboo instance to your Stash instance (and vice versa) via an ‘Application Link’. Without this the two applications will not be able to communicate with each other.

See Atlassian’s documentation on ‘Integrating Bamboo with Stash‘ for more information.

 

1. Create your first Bamboo Deployment Plan

Now that we have all the functionality we need in Stash to deploy our Salesforce code, it is time to create a Bamboo ‘plan’ that will execute deployments for us.

1.1 – In Bamboo, create a new plan by clicking on the ‘Create -> Create New Plan’.

Screen Shot 2015-04-13 at 12.41.49

1.2 – A new plan wizard will be launched to help you through the process. Each ‘plan’ has a parent ‘project’ – enter a name / description that is meaningful to you.

Screen Shot 2015-04-13 at 12.50.46

 

1.3 – In the ‘Source respositories’ section, select ‘Git’, and enter your repository URL. (remember: Stash is an application, but it manages code in Git repositories).

You will also need to select a default branch, and enter a username / password. For now, select a ‘Manual’ trigger, this means the job will only run when we tell it to.

Screen Shot 2015-04-13 at 12.55.15

When ready, click on ‘Configure tasks’. Next, we will instruct Bamboo to use Ant jobs to deploy Salesforce.

2. Configure your plan to use the Ant deployment tool

2.1 – On the ‘Configure tasks’ screen, ignore the ‘Source Code Checkout’ step, and click on ‘Add Task’. Find the Task type ‘Ant’ and click on it.

Screen Shot 2015-04-13 at 13.01.05

2.2 – The Ant Task needs to reference an ‘Executable’, which is the version of Ant you have installed on your Bamboo server. To set this up click on ‘Add new executable’.

Screen Shot 2015-05-08 at 11.13.44

The ‘Executable label’ can be anything, but the ‘Path’ needs to point to the local where Apache Ant is on your server (for how to install this, see ‘How to set up Salesforce deployment pre-requisites on a Linux Server (for Bamboo)‘).

2.3 – The Ant configuration needs to use the executable that you just set up. It also needs to know what to execute when the step runs (this is the build file, and the target). The JDK points to the location where Java is installed on your Bamboo server.

AntBambooConfig2.4 – Save the configuration, select ‘Enable this plan?’ and hit Save.

Screen Shot 2015-05-08 at 12.08.02

3. Try it out!

You can run the plan now… but it should fail. Try running it and you should get an error like the below:

BUILD FAILED
/home/ec2-user/bamboo/xml-data/build-dir/CIT-DEP-JOB1/build/build.xml:69: Can't assign value '${env.bamboo_maxPoll}' to attribute maxpoll, reason: class java.lang.NumberFormatException with message 'For input string: "${env.bamboo_maxPoll}"'

The cause of this issue is that Bamboo is finding the build.xml file, but we haven’t yet set up the ‘Bamboo Variables’ (e.g. what environment are we deploying to, what is the username and password etc) which our build.xml needs to receive.

4. Add Bamboo Variables to your plan

If you downloaded the build.xml from this tutorial then we need to create the below variables in Bamboo. These variables are passed to Apache Ant at the point of executing the Bamboo job.

Screen Shot 2015-05-08 at 14.09.29To add these, follow these steps:

4.1 – On the Plan page, click on ‘Actions’ -> ‘Configure Plan’.

Screen Shot 2015-05-08 at 14.13.46

4.2 – From here, select ‘Variables’ and then add all the values you need to.

Screen Shot 2015-05-08 at 14.16.39

4.3 – The downloadable XML requires the following variables:

  • checkOnly = FALSE
  • destructive_changes = TRUE
  • maxPoll = 5000
  • maxWaitMillis = 5000
  • username = <your Salesforce org username>
  • password = <your Salesforce org password> + <your Salesforce org security token>
  • serverUrl = https://login.salesforce.com or https://test.salesforce.com

4.4 –  Once you have added these variables, try to re-run the plan!

4.5 – It will run again, and this time the plan should start the deployment to Salesforce. You can check it by logging into your Salesforce org, and navigating ‘Deploy’ -> ‘Deployment Status’.

Screen Shot 2015-05-08 at 14.42.13You should see a record for your deployment, and be able to see how the deployment is going.

Screen Shot 2015-05-08 at 14.45.47
Your Bamboo job will probably at this point in the tutorial! it is common at this point. The reason, is that we are attempting to deploy the entire code base from one org to another, and sometimes doing this will cause deployment errors.

Resolving these deployment errors will allow you to complete the deployment process. In the next article I will help you resolve common deployment errors, so that you can use the Bamboo process without coming across errors!

 


<– Previous: Setting up the pre-requisites for Bamboo to execute Salesforce deployments

Next: Resolving Salesforce Metadata Deployment Issues –>


 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *


*

Seo wordpress plugin by www.seowizard.org.