In modern software development, teams often rely on CI/CD tools like **GitHub Actions**, **Jenkins**, **GitLab CI**, and **CircleCI** to automate application testing, version control, and deployments. These tools help enforce consistency across instances, reduce manual overhead, and improve release cycles by introducing automation at every stage of the software delivery process.
With **ToolJet’s git sync CI/CD APIs**, organizations can bring the same level of automation and control to their internal applications built on ToolJet. By integrating git sync with CI/CD pipelines, you can:
- **Automate Git operations** such as syncing, pushing, and pulling app changes.
- **Deploy apps across environments** like development, staging, and production without manual intervention.
In this guide, we will demonstrate how to integrate **git sync CI/CD** with **Jenkins**. The same approach can also be adapted to other automation tools like GitHub Actions or GitLab CI depending on your organization's preferences.
We'll use a sample scenario of an organization called **Pyratech**, which manages internal ToolJet applications across multiple instances.
Replace `$DEV_ACCESS_TOKEN` with the access token generated for the development environment. Similarly, set up git sync configurations for staging and production instances.
## 2. Setup Credentials in Jenkins:
1. In Jenkins, navigate to **Manage Jenkins > Manage Credentials > System**.
2. Click **Global credentials (unrestricted)**.
3. Add new credentials for each ToolJet instance such as BASE_URL, TOOLJET_ACCESS_TOKEN and GITHUB_ACCESS_TOKEN
4. Save the credentials.
## 3. Jenkins Pipeline Setup with Git Sync Operations
For our example, one of the approach would be to create a **single reusable [Jenkins pipeline](https://www.jenkins.io/doc/book/pipeline/)** that can execute different git sync CI/CD actions.
With this pipeline setup:
- Developers or DevOps teams can select the desired git sync action (setup config, push, pull, deploy, etc.) when triggering the pipeline.
- Sensitive credentials like ToolJet tokens and GitHub App keys are securely stored in Jenkins using **Jenkins [Credentials Manager](https://www.jenkins.io/doc/book/security/credentials/)**.
- The pipeline dynamically triggers the appropriate ToolJet git sync API endpoint based on selected parameters.
## 4. Jenkins Pipeline Actions
The Jenkins pipeline should include several stages corresponding to various git sync actions. Here’s a high-level overview of what each stage might look like:
**git sync Actions:**
| Action | Description |
|--------|-------------|
| **SETUP_GIT_CONFIG** | Configures the git sync connection for the organization with GitHub App credentials. |
| **PUSH_TO_GIT** | Pushes a specific app version from ToolJet to GitHub. |
| **CREATE_FROM_GIT** | Creates a new ToolJet application from the GitHub repository. |
| **SYNC_FROM_GIT** | Pulls the latest changes from GitHub into the specified ToolJet app. |
| **DEPLOY** | Deploys the app to the target environment. |
Each of these actions maps to a specific REST API call handled within the pipeline functions like `setupGitConfig()`, `pushToGit()`, `syncFromGit()`, and `deployApp()`. Click [here](/docs/development-lifecycle/cicd/example#3-jenkins-pipeline-setup-with-git-sync-operations) to see the full Jenkins file code snippet.