Skip to content

Git integration and branching

Version history (recipe 6.1) lives inside one Orchestrator. Connect that Orchestrator to a Git repository and the same history is pushed to a server your team already backs up, reviews, and understands. Each change you save on Orchestrator becomes a commit you can push to a branch, and changes others push to that branch can be pulled back in. Branches are what make Git useful for more than backup: in recipe 6.4 a development and a production Orchestrator follow two branches of one repository.

In this recipe you prepare a GitHub repository, connect vco01.vmw.lab to its develop branch, push the chapter’s content, pull a change made in GitHub, and roll the server back to an earlier commit. GitLab works the same way. Only the token page differs.

Getting ready

  • Administrator rights on vco01.vmw.lab, and the content from recipe 6.1 on it.
  • A GitHub account, and an empty private repository you can create branches in. This recipe calls it vcfguide-content. If you use GitLab, create a project instead.
  • vco01 able to reach github.com (or your GitLab server) on TCP 443. If the appliance goes out through a proxy, set that up first.
  • A VCF licence. Broadcom documents Git integration as needing a VMware Cloud Foundation licence. Every VCF 9 Orchestrator has one.

How to do it

Prepare the repository

  1. In GitHub, create the private repository vcfguide-content with a README.md, so it has a main branch.
  2. Create a second branch, develop, from main. vco01 will push to develop. main is for content that’s been reviewed (recipe 6.4).
  3. Create a fine-grained personal access token for Orchestrator. Limit it to the repository vcfguide-content, give it Contents read and write access, and set an expiry date you’ll remember. Copy the token: GitHub shows it only once.
Needs a lab check. Confirm on 9.1.1 that a GitHub fine-grained token with only Contents read and write is enough for validate, push, and pull, and whether a classic token with the repo scope is needed instead.

Connect Orchestrator

  1. On vco01, go to Administration > Git Repositories and click Add Repository. From 9.1.2, Git repositories are on the combined Administration > Repositories page, next to the package repositories for environments (recipe 4.3).
  2. Enter the repository’s HTTPS URL, https://github.com/<your-account>/vcfguide-content.git, your GitHub user name, and the token as the access token.
  3. Click Validate. Orchestrator connects to GitHub with the token and lists the branches it finds.
  4. Change the Name to vcfguide-content, and add a description such as VCF Orchestrator Guide content, development.
  5. Click Make active repository, choose the branch develop, and click Save.
  6. Back in the list of repositories, vcfguide-content shows the status Active.
Figure 6.9. Connecting Orchestrator to a GitHub repository.
Figure 6.10. The active repository.
Needs a lab check. On 9.1.1, record the exact field labels of Add Repository, whether the branch is chosen in a drop-down filled by Validate, and what Validate shows on success and with a wrong token.

Push the content

  1. Go to Administration > Git History. The page compares the server’s local history with the develop branch. Expand an entry to see which objects changed.
  2. Click Push. Enter the commit title Chapter 6 example content and, if you like, a short description.
  3. Select the changes to push. For the first push, select the workflow, the action, and the configuration element from recipe 6.1.
  4. Click Push. When it finishes, the entry shows as pushed.
  5. Open the develop branch in GitHub. There’s a new commit with your title, and the repository now holds the three objects as files, under folders for workflows, actions, and configuration elements.
Figure 6.11. Pushing a change set from Git History.
Figure 6.12. The pushed content on GitHub.
Needs a lab check. On 9.1.1, record what the first Git History view lists on a server that has never pushed (only your own content, or every object including the library), and the folder layout and file format Orchestrator writes to the repository.

Push from the editor

  1. Open Report powered-on VMs, change its description, and save.
  2. You don’t have to go to Git History for one object. The workflow editor has a version control at the bottom: use it to push this workflow’s change on its own, with a commit title.
Needs a lab check. Find the per-object push in the 9.1.1 workflow editor (the 8.16 documentation calls it the Version option at the bottom of the object editor) and record its label and dialog.

Pull a change made elsewhere

  1. In GitHub, open the file for vcfguide-ch6-settings on develop and change the value of reportPrefix from VCF Guide to VCF Guide (Git). Commit it to develop.
  2. On vco01, go to Administration > Git History and click Pull. Orchestrator fetches the new commit and applies it.
  3. Open vcfguide-ch6-settings. reportPrefix now reads VCF Guide (Git), and the element’s Version History shows the pull as a new entry. Change it back in Orchestrator, save, and push.
Needs a lab check. Steps 17 to 19 assume configuration element values are stored in the repository in plain text and applied on pull. Check both on 9.1.1, and whether editing the file in GitHub is accepted or rejected for a bad version number or signature.

Go back to an earlier commit

  1. In Git History, select the commit Chapter 6 example content and click Reset to this. Confirm with Ok.
  2. The server’s content is now exactly as it was at that commit: the workflow’s later description is gone. Content that didn’t exist at that commit is removed from the server altogether.
  3. To return to the latest state of the branch, click Pull.

How it works

Two repositories, one branch. Orchestrator already keeps its content in a local Git repository (recipe 6.1). Connecting an external repository links that local repository to one branch of a remote one. Push sends local commits to the branch. Before it does, Orchestrator brings in any commits on the branch that it doesn’t have yet and replays its own on top, as git pull --rebase would. The server log of a failed push in KB 314887 shows that rebase step. Pull brings the branch’s commits in and applies them to the server’s content. Only one repository can be active at a time, and it follows one branch.

Change sets. Git History shows the difference between the server and the branch as a list of change sets, one for each saved change. You choose which to push, and Discard all throws away every local change that hasn’t been pushed. Any workflow developer can push or discard a change set, whatever their group permissions. If that’s too open for production, keep developer roles off the production server (recipe 6.4).

Secrets never reach Git. When Orchestrator writes an object to the repository, it replaces every SecureString value with a __NULL__ placeholder. That’s deliberate: credentials don’t belong in Git history. It has a consequence you need to plan for. If the server ever replays the whole repository into its database, the placeholders overwrite the real values, and your passwords become empty. Broadcom KB 446735 lists what triggers that full re-sync:

  • making a different repository active,
  • changing the repository’s URL,
  • changing the branch it follows, for example from develop to main,
  • turning Git integration off and on again, in the client or through the API.

Choose the repository and branch once, before you push anything. If you must change them, write down every SecureString value first, so you can re-enter them afterwards. apiToken in vcfguide-ch6-settings is in the example to remind you.

Conflicts. A pull applies remote commits one after another. When a remote change and a local one touch the same object, the pull stops on a merge conflict, and each conflicting object has to be resolved before it can go on. Changes made by hand in the repository, including changes to line endings by a Git client on Windows, are the usual cause.

Needs a lab check. Create a pull conflict on 9.1.1 (change the same workflow in GitHub and on vco01, then pull) and record how the client presents it: the Resolve Conflicts window from recipe 6.1, or another dialog.

Limits worth knowing. Orchestrator only works with SHA-1 commit hashes. If an abbreviated hash in the local repository matches one in the remote, push fails with Could not resolve uniquely the abbreviated object ID, and the only way out is to discard or reset the local repository (KB 314887). Each Orchestrator has one SSH key, so to connect repositories from different accounts, use HTTPS with a token rather than SSH. Workflows generated by Generate CRUD workflows for a table aren’t tracked and can’t be pushed.

Back in vRO 5.5–7There was no Git integration. Export workflows or packages as files and commit them to source control yourself, or build them with VMware's Maven-based tools.
In Orchestrator 9.xConnect a GitHub or GitLab repository under Administration > Git Repositories, push and pull change sets from Git History, and reset the whole server to an earlier commit.

There's more

SSH instead of a token. Instead of an HTTPS URL and a token, you can enter the repository’s SSH URL. Orchestrator then authenticates with its own SSH key pair. Add its public key to the repository as a deploy key with write access. The REST API returns the key with GET /vco/api/content-repositories/public-keys.

Needs a lab check. On 9.1.1, find where the client shows Orchestrator’s public SSH key for Git, and confirm the path of the public-keys call (the 9.1 API reference lists Get Public Keys under the Repository (Version Control) Service).

Restoring one workflow from Git. Pull and Reset to this work on the whole server. There’s no way to pull a single file. To get back one workflow that was deleted from Orchestrator but still exists in Git, Broadcom’s KB 453014 suggests a detour: import the workflow’s file from the repository into a sandbox Orchestrator, put it in a package there, and import that package into the server that lost it. Try Deleted Items first (recipe 6.1). It’s much quicker.

Large pulls. Pulling many commits with many conflicts can run into the database transaction timeout. Broadcom KB 452775 suggests squashing or rebasing the branch in Git first, and, if that isn’t enough, raising the timeout from the appliance’s root shell:

Raise the database transaction timeout (KB 452775)
vracli vro properties set -k com.vmware.o11n.db.transaction.timeout -v 1200

Back up the appliance before changing properties (recipe 2.6).

Needs a lab check. Check on 9.1.1 that vracli vro properties set accepts this key and that it needs no restart. KB 452775 was written for 8.18.

Push and pull from a pipeline. Everything in Git History is also in the REST API’s Repository (Version Control) Service: GET /vco/api/content-repositories/state shows how far the server is ahead of or behind the branch, and push and pull are requests, such as POST /vco/api/content-repositories/requests/pull, that you start and then poll until they finish. A scheduled workflow or an external pipeline can pull every night, so a server never drifts far from its branch.

Needs a lab check. Run a pull and a push through the 9.1 REST API on vco01 and record the request bodies, the status values to poll for, and the response when a merge conflict stops a pull (KB 452775 describes a MERGE_CONFLICT status with the conflicting paths).

Clusters. A three-node cluster (recipe 2.4) shares one database, and so one local repository and one connection. Set up Git once, on any node’s client.

Needs a lab check. Confirm on a 9.1.1 cluster that the Git connection and Git History are shared by all nodes.

See also