Operations 8 min read

Automating Feature and Release Branch Management with Jira, GitLab, and Jenkins

This guide explains how to integrate Jira, GitLab, and Jenkins to automatically create feature branches for new issues, generate release branches, and manage merge requests in a micro‑service architecture, detailing the required webhook configuration, pipeline setup, and shared Groovy library functions.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Automating Feature and Release Branch Management with Jira, GitLab, and Jenkins

1. Requirement and Code Management

Jira is used for requirement and defect tracking with Scrum, while GitLab hosts the code repositories; each micro‑service corresponds to a GitLab project under a group named after the business abbreviation (demo). Feature branches are created automatically when a Jira issue is linked to a module, and release branches are generated from the main branch once feature development is validated.

2. Configuration Process

The toolchain consists of Jira, GitLab, and Jenkins. Jira creates issues and triggers a webhook; Jenkins receives the webhook, parses the data, and calls GitLab APIs to create feature or release branches.

2.1 Preparation

In Jenkins, a Pipeline job with a GenericTrigger is configured to receive projectKey , webHookData , and token parameters from the Jira webhook.

triggers {
GenericTrigger( causeString:'Trigger By Jira Server -->>>>> Generic Cause',
genericRequestVariables:[[key:'projectKey',regexpFilter:'']],
genericVariables:[[defaultValue:'',key:'webHookData',regexpFilter:'',value:'$']],
printContributedVariables:true,
printPostContent:true,
regexpFilterExpression:'',
regexpFilterText:'',
silentResponse:true,
token:"${JOB_NAME}"
)
}

The Jira webhook URL is configured as http://jenkins.idevops.site/generic-webhook-trigger/invoke?token=demo-jira-service&projectKey=${project.key} . The webhook payload is parsed in the Jenkinsfile using readJSON to extract fields such as webhookEvent and issue details.

2.2 Encapsulating GitLab API

A shared Groovy library ( src/org/devops/gitlab.groovy ) provides helper methods for HTTP requests, file updates, branch creation, merge request handling, and status changes. Example functions include HttpReq , CreateBranch , CreateMr , and AcceptMr , each wrapping the corresponding GitLab REST endpoints.

def HttpReq(reqType,reqUrl,reqBody){
    def gitServer = "http://gitlab.idevops.site/api/v4"
    withCredentials([string(credentialsId:'gitlab-token',variable:'gitlabToken')]){
        result = httpRequest(
            customHeaders:[[maskValue:true,name:'PRIVATE-TOKEN',value:"${gitlabToken}"]],
            httpMode:reqType,
            contentType:"APPLICATION_JSON",
            consoleLogResponseBody:true,
            ignoreSslErrors:true,
            requestBody:reqBody,
            url:"${gitServer}/${reqUrl}"
        )
    }
    return result
}

def CreateBranch(projectId,refBranch,newBranch){
    try{
        def branchApi = "projects/${projectId}/repository/branches?branch=${newBranch}&ref=${refBranch}"
        def response = HttpReq('POST',branchApi,'').content
        def branchInfo = readJSON text:"""${response}"""
    }catch(e){
        println(e)
    }
}

2.3 Shared Library Configuration

The shared library is added to the Jenkins pipeline, allowing the pipeline script to call the encapsulated GitLab functions for creating branches, merge requests, and updating repository files as part of the automated workflow.

About Us

Ze Yang, a DevOps practitioner, shares enterprise‑level DevOps operations and development techniques, focusing on Linux operations, DevOps courses, and practical experience drawn from real‑world projects.

CI/CDMicroservicesDevOpsGitLabJenkinsJira
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.