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.
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.
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
- Make sure Security for all Git repositories is visible
- Click Add...
- Search for Project Collection Build Service or Project Build Service, displayed with a gray colored user icon. Ignore the purple groups.
- Select the user and click Save changes
- Match the permissions to the screenshot below. Toggle the Not set text to Allow by clicking on it. Then click Save 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.