function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Antonio Criado 7Antonio Criado 7 

How to integrate Salesforce - Git for CI

Hi,
I am trying to integrate Salesforce with some Git repository but I have no idea of what to use. Salesforce recommend to use Ant IT but I have seen a lot of Jenkins tutorials but nothing up to date. My idea is to work as a team and forget to commit our code to git, any ideas? Thank you in advance
pranav_sanvatsarkarpranav_sanvatsarkar
Hi Antonio Criado 7,

Welcome to the world of automation!

I belive that you may need to clarify a few concepts before attempting to implement the desired integration.

Git is a version control mechanisim which stores copies of human readable files such as .txt, .aspx. .apxc, etc. Git can be used only to maintain versions of our code / metadata and not to do any type of automatic deployment. Though there are UI based dekstop tools like GitHub or SourceTree, all the Git commands are available through command-line tools as well. 

Ant Migration Tool is a desktop based deployment utility provided by Salesforce to deploy source code and metadata from local file system to Salesforce instance. It is basically command-line-based utility where you can write commands to deploy the source files.

Jenkins is an executioner utility which basically does the task of executing whatever we instruct it to do. We can instruct it to execute some commands on command line utilities as well e.g. batch file for windows dos. It also has some plug-ins to perform git based operations such as push and pull.

So this is how I would suggest you to implement the automation.
  1. Install and configure Jenkins on local or a remote server which is accessible on the internet ( this is necessery for GitHub to send message to notify changes ). Ultimately we need to configure a webhook.
    1. Configure Jenkins to support Git commands and DOS
    2. Provide github user credentials to allow pull command
    3. Configure Ant Tool or Salesforce CLI on the same server / machine as Jenkins
    4. Provide Salesforce user credentials to allow to deploy the metadata
  2. Configure Github to send notification on Webhook of Jenkins server

This is the expected flow,
  1. We push code to Github
  2. Github sends a notification to Jenkins server to pull the code
  3. Jenkins uses Gihub user credentials to pull changes from repository to local file system
  4. It then uses Salesforce user credentials to deploy the code on the local file system

Hope this helps!

Thanks,
Pranav Sanvatsarkar.