How to Set or Change ServiceNow Application's Repository URL, Credentials, or SSH Key

Whether you’ve been getting the dreaded “Repository authentication failed” error message in ServiceNow, or you just want to change which Git repository your ServiceNow application is associated with, this article will help you out. I’ll walk you through the steps to properly set up authentication with Github, and configure (or alter) the Git/Github repository your application is linked with.

“Repository authentication failed, check credentials. Make sure the user has both read and write access”

Unfortunately, ServiceNow has made the interesting (see: baffling) decision to make it confoundingly difficult to figure out how to change the Git repo your application is associated with, once it’s been linked to one. I can’t fathom why they might’ve done this, but that is unfortunately not an unusual sentiment when it comes to ServiceNow.

Knowing that I’m liable to let this article devolve into a 10-page ranting, rambling manifesto lamenting the unnecessarily opaque and undocumented process for doing basic things like changing the repo your application is associated with, let’s instead get straight on in to how to do it anyway.

Generating an SSH Key for Github/ServiceNow

If you haven’t already got one set up (such as if your new repo is associated to a new Github account), you’ll need to first generate an SSH public/private key pair. This will allow your ServiceNow instance to authenticate to your your Github account and repositories.

  1. Using a tool such as this one, enter a passphrase and click Generate-SSH-Keys. Save the Public and Private keys somewhere temporarily, and don't forget the passphrase! You’ll need all three of these in a moment.

    1. UPDATE: Github is deprecating the usage of RSA keys, so you’ll want to make sure that you select ECDSA for the SSH-Keygen Algorithm. This uses elliptic curve cryptography and is more secure than RSA.

  2. From Github, click your profile icon and go to Settings.

  3. In the Access section on the left of the page, click on SSH and GPG keys.

  4. Click the green New SSH key button at the top of the page, next to the SSH keys section header.

  5. Give your new SSH key a title like "ServiceNow {instance name}" and paste the Public key into the Key field, then click the green Add SSH key button.

  6. In your ServiceNow instance, navigate to the Credentials [discovery_credentials] table, and click New. This will take you to an Interceptor page with a list of options for the credential type.

  7. For the type, scroll to the bottom of the list, and click on SSH Private Key Credentials.

  8. Name the credential record something meaningful, so you won’t forget which Github account it corresponds to. Enter your Github username, your Github password, the SSH passphrase, and the SSH private key you generated in step 1.

  9. Save the Credential record.

Changing Your Application Repository/URL

Now that you’ve got your credential record sorted out and linked up with Github, let’s change your application’s repo URL!

  1. Open up Studio in ServiceNow. Commit all changes to your old source control repo, and export your app to XML as a backup -- just in case.

    1. To export your app to XML, follow these steps, then navigate to the Update Set, close it, and click Export to XML in the Related Links UI Actions.

  2. Navigate to the sys_repo_config table (you can just enter sys_repo_config.list into the Application Navigator filter bar and press Enter)

  3. Find any repo config records that are associated with your application (sys_app={YOUR_APP_SYS_ID}).

  4. Check the box next to the repo your application is currently associated with, and from the Actions drop-down menu below the list (or above it, if you’re on the new Polaris UI), choose Delete.

    1. You’ll probably be notified that some number of Source Control Branch records will be deleted as well as possibly some Tags and other related records. This is fine.

  5. Open ServiceNow's Application Studio (or refresh the page if you already had it open)

  6. Click the Source Control menu at the top, and you'll see that only Link to Source Control is available. This means the application is no longer linked to your old repo! (That’s good.)

  7. Click Link to Source Control and follow the steps as normal once you have the new Git repo set up.


That’s it! If you found this article helpful, please consider subscribing. We tend to only send out emails a few times a year at most. Feel free to also follow me on Twitter and LinkedIn, if you feel so inclined. I’d love to hear what you thought of this article, and if you have any feedback!

Thanks for reading!