Streamline Your ServiceNow Development: Connecting Instances to Git for Seamless Change Management

maheshchokkara
Tera Contributor

Hi Community,

This technical guide, focusing on a crucial process for ServiceNow developers: connecting ServiceNow instances to Git for seamless change management. This guide is particularly valuable given that Personal Developer Instances (PDIs) can expire, potentially leading to lost work during Proof of Concept (POC) development. By leveraging Git, you can effectively deploy changes from your repository directly into ServiceNow.

  1. Two ServiceNow Personal Developer Instances (PDIs):

 

Linking Your ServiceNow Instance to GitHub

 

 

Step 1: Create a New Repository on GitHub

 

The first step is to set up your repository on GitHub. This will be the central hub for your ServiceNow application's code.

  1. Login to GitHub Account and Navigate to GitHub Dashboard.

  2. Click on Create new repository.

  3. Give the Repository Name: "your_own_name".

  4. Click Create to finalize the repository creation.

    maheshchokkara_0-1752684162034.png

    GitHub Application Repository Created:

    maheshchokkara_1-1752685182720.png

     


    Step 2: Create a Credential Record in ServiceNow

     

    To enable your ServiceNow instance to communicate with your GitHub repository, you'll need to create a credential record.

    1. In the main ServiceNow window (outside of Studio), use the All menu to open Connections & Credentials > Credentials.

              2. Click the New button.
              3. From the What type of Credentials would you like to create? list, select Basic Auth Credentials.

maheshchokkara_2-1752685292080.png

 

 

               Now, configure the Basic Auth Credentials record with the following details:              

               4. Name: GitHub Credentials - <your GitHub Username> 
               5. User name: <your GitHub Username>
               6. Password: token (This is where your Personal Access Token will go, which we'll generate next).

maheshchokkara_3-1752685559102.png

 

 

Generating Your GitHub Personal Access Token

 

A Personal Access Token (PAT) acts as a secure password for programmatic access to your GitHub account.

  1. Go to your GitHub Profile.

  2. Navigate to Developer settings.

  3. Generate a New token (classic), ensuring you grant appropriate permissions (typically repo scope for full control over repositories).

    • Tip: Select "Tokens (Classic) > Generate New Token (Classic)" for this process.

  4. Once generated, copy this new token immediately as you won't be able to see it again.


maheshchokkara_4-1752685674874.png

 


maheshchokkara_6-1752685737261.png



Step 3: Link Your Application to Source Control (ServiceNow Studio)

 

With your GitHub repository and ServiceNow credentials set up, it's time to connect your ServiceNow application to source control via ServiceNow Studio.

  1. Open ServiceNow Studio.

  2. Open the specific application you wish to link.

  3. Go to Source Control > Link To Source Control.

  4. Provide the repository URL from GitHub and select the Basic Auth Credentials you created earlier.

  5. Update the branch name instead of following default. and Click Link To Source Control.

maheshchokkara_8-1752686030530.png

maheshchokkara_9-1752686076300.png

 


Once the linking process is complete, you can start seeing changes of your instance (e.g., tables and ACLs) reflected in your repository.
maheshchokkara_10-1752686274570.png


maheshchokkara_11-1752686389624.png

 

 

Step 4: Manage Changes and Commit to Git 

  Once your application is linked, any modifications you make within it can be committed directly to your GitHub repository.
  1. Make changes in your source instance: Implement your desired updates to flows, tables, or other  application components.

 2. Commit the updated changes: From ServiceNow Studio, commit these changes to your linked  GitHub repository. This effectively versions your work.

maheshchokkara_12-1752686532146.png

    3. Above are the files I committed to GitHub repository.


Step 5: Deploy Changes to a Target Instance

 

To push your committed changes to another ServiceNow instance (your target instance), follow these steps:

  1. On the target instance, open ServiceNow Studio.

  2. Click Import Application and Update Repository link and Credentials same as source

  3. Click Import.

    maheshchokkara_13-1752686773555.png




      Step 6: Verify Your Deployment

                        Source Instance: (Created a flow and added one Update action)
maheshchokkara_15-1752687200999.png

                                Target Instance: (Shows the same flow as the source)
maheshchokkara_14-1752687075201.png


    

Propagating Updates:

 Now, let's say I've updated the flow in the source instance with the description "Successfully Change  Moved."


               Source Instance:
maheshchokkara_16-1752687343265.png

                   Here we can see only the latest changes that are available in application on source instance
maheshchokkara_17-1752687447969.png

 


                          The Updated Flow is committed using studio
maheshchokkara_18-1752687799325.pngmaheshchokkara_19-1752687862481.png



          1. Open the application On the target instance, Go to Source Control > Apply Remote Changes.
          2. This action will fetch the latest changes from your GitHub repository. You'll typically see a prompt to Confirm Merge and done.

          3.GitHub: click the create Pull request of your branch

maheshchokkara_20-1752688029616.png

          4. If you're managing multiple branches or encounter conflicts, you may need to select merge pull request to integrate the changes correctly.

maheshchokkara_21-1752688143616.png

 
              5. Go to Source Control > Apply Remote Changes on Target Instance

maheshchokkara_22-1752688330610.pngmaheshchokkara_23-1752688381348.png



Result:

        The final step is to confirm that your changes have been successfully deployed to the target instance.

  • Verify updates on the target instance: Check that the changes you made (e.g., updated flows, new tables) are now present and fully functional on your target ServiceNow instance as you see description updates as "Successfully change Moved"

    maheshchokkara_24-1752688461650.png

     



    References:

    This guide draws upon information and best practices outlined in the official ServiceNow product documentation



    Conclusion:

    This guide provides a robust method for managing your ServiceNow development. It ensures your work is backed up, version-controlled, and easily deployable across instances, even if your PDI expires. This process significantly streamlines the deployment of your innovations.

 

0 REPLIES 0