Mid Version Control

How do you integrate Git with Jenkins, GitLab CI, or GitHub Actions?

Integration means connecting your Git repository to your CI/CD system so every

push, pull request, or tag triggers an automated build, test, and deploy pipeline.

✅ Jenkins Integration

  • Install the Git plugin in Jenkins.

Create a new pipeline job and link it to your Git repository:

pipeline {

agent any

stages {

stage('Checkout') {

steps {

git branch: 'main', url:

Follow:

stage('Build') {

steps {

sh 'npm install'

sh 'npm test'

  • Jenkins polls Git or listens for webhooks to trigger builds automatically.

✅ GitLab CI/CD

GitLab CI is built-in — simply create .gitlab-ci.yml:

stages:

  • test
  • deploy

test:

script:

  • npm install
  • npm test

deploy:

script:

  • ./deploy.sh

only:

  • main

Every push triggers this pipeline automatically.

✅ GitHub Actions

GitHub has its own YAML-based workflows:

name: Node CI

Follow:

on: [push, pull_request]

jobs:

build:

runs-on: ubuntu-latest

steps:

  • uses: actions/checkout@v4
  • run: npm ci
  • run: npm test

It runs directly in GitHub without needing extra setup.

Real-world example:

Your team pushes code to GitHub → GitHub Actions automatically runs tests →

Jenkins (or GitLab CI) deploys to a staging environment → Approval required for

production deploy.

More from Developer Essentials

All questions for this course