Source Control
If you keep your Runbooks in Git, you can link a PowerShell Runbook to a .ps1 file in a repository and pull the file into the Runbook editor in Runbook Manager.
Supported repositories:
- GitHub (github.com)
- Azure DevOps Git (dev.azure.com)
Code is only pulled from Git into the editor. Nothing is pushed back to Git, and nothing is saved, published or run until you do it yourself.
Notice: GitHub Enterprise, other Git hosts and TFVC are not supported. This feature is not the same as the Source Control integration in Azure Automation, which can be used independently of Automation App.
Prepare authentication
Public repositories can be read without authentication.
For a private repository, a ServiceNow administrator must create a Basic Auth Configuration in ServiceNow:
- Create a personal access token (PAT) in GitHub or Azure DevOps that can only read the repository.
- In ServiceNow, navigate to System Web Services -> REST Message -> Basic Auth Configuration and click New.
- Enter a name, a username and the PAT as password. For Azure DevOps any non-empty username works.
Notice: Everyone who can read a Runbook linked to the repository can read the linked file through this connection. Use a token that only has read access to the repositories you need.
Add a repository connection
Repository connections are added per Automation Account. You need the x_autps_azure_auto.admin role.
- In Automation Workspace, open Setup and select the Automation Accounts tab.
- Click Repositories next to the Automation Account.
- Click New repository connection.

Fill out the form:
| Field | Description |
|---|---|
| Repository connection name | A name that makes sense to you. |
| Git provider | GitHub or Azure DevOps Git. |
| Repository HTTPS URL | The HTTPS URL of the repository, for example https://github.com/contoso/runbooks. |
| Default Git branch | The branch used unless a Runbook overrides it, for example main. |
| Allowed base folder | Runbooks can only be linked to files in this folder, for example Runbooks. |
| Native authentication profile | The Basic Auth Configuration created above, or No authentication (public repository) for public repositories. |
| Repository connection active | Clear it to stop the connection from being used. |
Click Save repository connection. Saving does not contact Git or Azure. You can add more than one connection to an Automation Account.
Link a Runbook to a file
- Open a PowerShell Runbook in Runbook Manager.
- Click Source control.
- Select the Repository connection.
- Optionally enter a Git branch override.
- Enter the Repository .ps1 path, including the file name, for example
Runbooks/Windows/Restart-Service.ps1. - Click Save repository binding.

You can link a published Runbook without entering edit mode. The link does not change the Runbook.
Pull code from Git
- Open Source control in the Runbook.
- Click Check for Git updates. The latest commit on the branch is read, and the file is shown next to your current editor content.
- If the Runbook is published, click Enter Edit to create a draft.
- Click Load into editor. If you have unsaved changes, you are asked to confirm that they are replaced.
- Review the code and click Save draft.
- Test and publish the Runbook as usual. See Runbooks.
When you save a draft loaded from Git, Automation App records which commit the code came from, and whether you changed it before saving. Matches last verified Git snapshot tells you if your editor content still matches that commit. Click Check for Git updates again to look for newer commits.
If the commit could not be recorded after a successful save, click Retry saved-draft verification. This does not save the draft again.
Limitations
- Only PowerShell Runbooks can be linked.
- Files must be UTF-8 text of at most 65,000 characters.
- Binary files, Git LFS files, symbolic links and submodules are not supported.
- A missing file, deleted branch or failed check never changes the code in your Runbook.