Azure DevOps (VSTS)
Learn how to connect Blue Canvas with Azure DevOps (VSTS - Visual Studio Team Services)
It can be useful to get your Salesforce code and metadata into Azure DevOps (Visual Studio Team Services). Blue Canvas makes it easy to keep your declarative and configuration changes synced directly between Salesforce and VSTS.
Before you start, familiarize yourself with Git and how to clone your Blue Canvas repository to make an external copy.
Initial import
Start by creating a new project in Azure DevOps.
- Click Create project. Enter a project name and click Create.
The project starts out with an empty repository. Run an initial import to populate it.
- Go to Repos. Click Import a repository → Import.
- Select Git as the source type
- Copy and paste
https://git.bluecanvas.io/...
into the Clone URL - Select Requires authorization
- Enter your Blue Canvas username and password
- Click Import
- Sit back and wait for the import to finish.
You now have a snapshot copy of Blue Canvas in Azure DevOps. Well done!
Note: The initial import into Azure DevOps doesn't copy binary files (e.g. Documents, StaticResources) because they are stored in Git LFS. Follow the next steps to copy those files.
Prepare security settings
Azure Pipelines uses a dynamic security model to control who can read or write to the repository. Before you can configure an automated importer pipeline, you need to add explicit permissions to allow $(System.AccessToken)
to write to the repository.
- Go to Project settings → Repos → Repositories
- Stay on the page titled All Repositories and go to Permissions
- In the search field, enter Project Collection Build Service
- Match the permissions to the screenshot below.
- Select Users → Project Build Service
- Match the permissions to the screenshot below.
- Select Groups → Project Collection Build Service Accounts
- Match the permissions to the screenshot below.
Automatically import changes
You are ready to set up an automated build script to periodically pull new changes.
- Go to Pipelines → Builds and click New pipeline
- Click Other Git when asked to select the source
- Click Add connection
- Copy and paste
https://git.bluecanvas.io/...
into the Git repository URL - Enter your Blue Canvas username and password and click OK.
- Enter the name of any Blue Canvas branch in Default branch for manual and scheduled builds, for example
prod
, and click Continue.
- When asked to select a template, click Empty job
Now you need to adjust the configuration and add a script.
- Select Get sources. At the bottom of the screen enable Checkout files from LFS.
- Select Agent job 1.
- For Agent pool choose Hosted Ubuntu 1604.
- At the bottom of the page under Additional options enable Allow scripts to access the OAuth token.
- Click the blue + button to add a new task. Search for Command line and add it.
- Select the new Command Line Script entry and paste the script snippet below.
- Replace the
<AZURE_CLONE_URL>
placeholders with the Azure Git clone URL. You can find the URL in Azure DevOps under Repos → Files → Clone → HTTPS.
set -ex
export AZURE_CLONE_URL="<AZURE_CLONE_URL>"
git show-ref
git for-each-ref --format='%(refname:lstrip=3)' 'refs/remotes/origin/*' | while read -r name; do git branch --track $name origin/$name; done
git branch -l
git lfs fetch --all
git remote remove origin
git remote add azure $AZURE_CLONE_URL
git config http.$AZURE_CLONE_URL.extraHeader "Authorization: Bearer $SYSTEM_ACCESSTOKEN"
git config lfs.$AZURE_CLONE_URL.git/info/lfs.locksverify false
git push --mirror --progress azure
Check for conflicting URL prefix
Some versions of Azure DevOps contain an additional prefix in the clone URL that will cause authentication errors in Git LFS. If the URL contains
DefaultCollection/
, delete that part from the string.
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.
Next Steps
If you want to run the build script automatically, VSTS allows you schedule builds. Click Triggers and select Scheduled to set it up.
Troubleshooting
Identify your Azure DevOps / VSTS version
https://{hostname}/{organization}/_home/About
Updated over 1 year ago