The Blue Canvas Developer Hub

Welcome to the Blue Canvas developer hub. You'll find comprehensive guides and documentation to help you start working with Blue Canvas as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Visual Studio Team Services and Salesforce

It can be useful to get your Salesforce code and metadata into Visual Studio Team Services. Blue Canvas makes it easy to keep your declarative and configuration changes synced directly between Salesforce and VSTS.

Clone Your Blue Canvas Repo

It’s useful to clone your Blue Canvas repo locally first. To do so, visit the Branches tab in Blue Canvas and scroll down to the Blue Canvas Git - Command Line Instructions. Here you will see your Git repo URL:

Run the git clone command on the command line. To name the directory that this Git repo lives in on your local file system, add a directory name of your choosing to the end of the command like so:

git clone -o salesforce -b master https://git.bluecanvas.io/t6a289876a56-df47-4226-b497-c2f6bc2a121e/r1a019c88-220e-40d5-81e6-2b5476dc6681.git my-repo

This will clone your Blue Canvas repo into a directory called my-repo.

Note: you will need to have Git installed to do this.

Create A Visual Studio Team Services Repo

Next we need to go to Visual Studio Team Services and either create a new project or select an existing one.

For simplicity we’ll start with a new project.

Name your project and select “Git” when asked for Version Control:

Select Push an Existing Repository from the Command Line from the repo’s home page.

Now we need to add VSTS as a remote to our existing git repo that we have cloned locally.

Use the command prompts to create a new remote for your existing repo. Note that they use origin as the default remote name for VSTS. You may prefer to use something like vsts.

git remote add vsts https://bluecanvas.visualstudio.com/_git/Blue%20Canvas%20VSTS%20Demo

git push -u vsts --all

Note: You will need to set up a Personal access token in order to push to your VSTS remote. You can do this by clicking your username in the top right corner and selecting Security and adding a new token.

Now VSTS is set up as a remote. You can now pull changes that happen from Blue Canvas to your local repo and push them to vsts by pushing to that remote like so:

git pull salesforce <branch name>
git push vsts <branch name>

This is useful. But VSTS actually lets us automate this process.

Automating Salesforce Code Sync with VSTS

Create a build definition in VSTS. Do this by visiting Build & Release at the top of the page. You can create a new build definition by clicking +New Definition. For simplicity we can start with an empty definition. Select your repo here.

Once it’s created we need to create 4 build steps.

Install Variable Tool Box and Transform Build Variables

First, install the Variable Toolbox VSTS plugin. This allows us to manipulate our build variables. Once you’ve installed this you can add your first build step which is the Transform value step:

VSTS has two variables that contain information about the branch we’re building: Build.SourceBranch and Build.SourceBranchName. Neither quite works for what we need to do. This Transform variable step allows us to replace ref/heads with a null string so that we can just grab the branch name without having it say refs/heads/mybranch/mybranch for example.

Git Checkout Branch

Next we need to run some command line scripts to interface with Git. You can just add three right away to your build step. The first step is to checkout the appropriate branch in Git. T

Tool should be git and arguments should be checkout $(GitBranchName). Click into Advanced and add $(Build.SourcesDirectory) as the working folder.

Git Pull from Blue Canvas

The next step is simple. We just need to pull our code from Blue Canvas using git pull. To do so again set git as your tool in the third build step. For arguments you’ll want to pull from Blue Canvas using the Git URL we used before.

You need to pass your Blue Canvas user credentials as a part of the URL. The format takes the form: https://BLUE_CANVAS_USERNAME:BLUE_CANVAS_PASSWORD@git.bluecanvas.io/6a28fa56-df47-4226-b497-c2f68ff90bbda121e/r1a0c3po-220e-40d5-81e6-2b5r2d2c3po6681.git.

Your Blue Canvas username is the email address you use to log into Blue Canvas. Note that you will need to use the special character %40 in place of the @ because you cannot have to @ signs in the URL. For clarity here is a full example:

https://jane.doe%40example.com:pA$$w0Rd@git.bluecanvas.io/6a28fa56-df47-4226-b497-c2f68ff90bbda121e/r1a0c3po-220e-40d5-81e6-2b5r2d2c3po6681.git.

VSTS allows you to create custom build variables so that you don’t have to hard code your Blue Canvas credentials in plain text.

Git Push to VSTS

Finally we need to push to VSTS. This is done similarly to pulling but instead of using git pull we use git push and we use our VSTS repo URL.

We’ll need to use our VSTS personal access token in order to do this. To pass this through you simply add the Personal Access Token to the repo URL like so:

push https://:VSTS_PERSONAL_ACCESS_TOKEN@bluecanvas.visualstudio.com/_git/Blue%20Canvas%20VSTS%20Demo

Note that the format is slightly different for VSTS than for Blue Canvas. You need an extra : after the https:// like so https://:token not https://token.

Save your build definition and run queue it to run. You will see that it pulls down changes and commits it to VSTS. You can now make changes in Salesforce through the UI, have Blue Canvas automatically commit those changes to Git and then use this build definition to pull those changes into VSTS.

Scheduling the Build

If you want to do this automatically, VSTS lets you schedule builds. Click Triggers and select Scheduled to setup the build to run automatically.

In the future Blue Canvas will also allow you to have it just work automatically on each commit. Stay tuned!