Will Hallam
ServiceNow Employee
ServiceNow Employee

Here's an example of using Studio's source control integration to track your ServiceNow application development via GitHub.

Create Credential

You will need to add a credential to your ServiceNow instance so it can perform actions in your GitHub repositories.  If you have already done so, you can skip this step; it is not required that Studio have its own credential.

Add an SSH key to your GitHub account, as in https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account.

In your ServiceNow instance:

  • go to Connections & Credentials->Credentials
  • Click "New"
  • Select "SSH Private Key Credentials"
  • Populate the following fields:
  • "Name" - assign a meaningful name
  • "SSH Private Key" - must contain the private key contents corresponding to the key you created/added to GitHub above

find_real_file.png

Create GitHub Repository

In your GitHub account:

  • Navigate to the Repositories page.  Click "New" and provide a meaningful Repository name.
  • Select Public or Private as applicable.
  • Click Create repository.

find_real_file.png

  • After clicking "Create repository", ensure that "SSH" is selected in the "Quick setup" section.  Copy the SSH URL into your clipboard.find_real_file.png

Link to Source Control

In your ServiceNow instance:

  • Navigate to your scoped application in Studio.  Select "Source Control"->"Link to Source Control".
  • Populate the resulting dialog box as follows:
    • Network protocol: select "ssh:
    • URL: paste the URL from GitHub here
    • Branch: generally the default is good here; if you have an alternate branch naming you want to use, update as applicable
    • MID Server Name: if you are segregating MID server usage, select a MID with access to GitHub here
    • Credential: select the credential you added above
  • Click "Link to Source Control"

find_real_file.png

  • Verify the operation is successful; if you do not see success, it is usually helpful to set MID logging to the maximum and retry the operation.  Common issues are network connectivity or GitHub permissions.
Comments
Sean43
Mega Explorer

Not able to Link to github following your instruction except using midserver. However, my local machine is able to talk to github. So from there i feel something is NOT correct in the ServiceNow side. I will try using midserver and update here.

Sean43
Mega Explorer

After setting up the midserver, it did work. I see github has moved from basic auth protocol to more secure like SSH private auth, personal token and oauth2.0. This is good.

CezaryBasta
Tera Guru

@Will HallamI just tried to follow your instructions and it requires small update - the article at GitHub you posted (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your...) suggest to use ed25519 type for ssh. However, this doesn't work with ServiceNow credentials, at least in Utah:

{
    "error.message":"Repository authentication failed, check credentials. Make sure the user has both read and write access",
    "exception.message":"org.eclipse.jgit.api.errors.TransportException: <secret_repo>: DefaultAuthFuture[ssh-connection]: Failed (RuntimeException) to execute: java.security.NoSuchAlgorithmException: Unsupported key type (ssh-ed25519) in null",
    "exception.class":"com.glide.sourcecontrol.SourceControlException",
    "error.code":"1001"
}

Adding an RSA type key however is working fine.

Ashley
Kilo Sage

Hi @CezaryBasta, I'm having the same problem, did you manage to resolve this?

Kind Regards

Ashley

CezaryBasta
Tera Guru

Hi @Ashley , yes I did, the solution is to simply use the RSA key, not the ed25519.

davidglover
Giga Expert

Sharing my experience in case it helps someone else.  I did the above, tested the RSA key on my local machine and it worked, but no matter how many times I tried, ServiceNow would not connect using the Private Key.

 

The error being logged was: 

The repo cannot be accessed. Check URL, username, and password, and confirm user has read, write, and create branch access: com.glide.sourcecontrol.SourceControlException: org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin: 	com.glide.sourcecontrol.AGitRepository.loadGit(AGitRepository.java:234)

 

I eventually created a Fine Grained Personal Access Token and that did work (to my surprise).  I followed most of the instructions here

 

The SSH Key had Read/Write access, not sure what the problem was.

Dan Covic2
Tera Contributor
Marc Mouries
ServiceNow Employee
ServiceNow Employee

You should use this support article to create a Github credential:

 
Menna Kearns
Tera Guru

After pouring over the developer forum and trying out multiple suggested solutions, finally got this working using the Fine Grained Personal Access Token as suggested by @davidglover (thanks!)

awesomevaran
Giga Contributor
Mexiprince
Kilo Sage
Kilo Sage

Do this:

Go to github.com, sign in.
Navigate to "Settings" under the user menu.
Navigate to "Developer" 
Create a new token under the Personal Access token either Fine grained or Classic.
Enter the created token as the password within the credentials used for GitHub in ServiceNow

ArleshaM
Tera Explorer

This article gives very detailed instructions on how to link a studio app to GitHub: https://developer.servicenow.com/blog.do?p=/post/backup-your-pdi/

 

You can also follow along using this video tutorial:  https://www.capcut.com/s/Cc3aaJZ1avC34yMn/

TomášD
Tera Contributor

Creating a classic token within my Github account and using this token as a password for ServiceNow connection worked well for me. Note: even though you use a token, it is still a https network protocol, not ssh.

Go to Settings -> Developer settings -> Personal access tokens -> Tokens (classic)

Version history
Last update:
‎01-10-2022 09:40 AM
Updated by: