Auto‑Trigger Jenkins Builds with Gitee Webhooks Using Generic Webhook Trigger
This tutorial explains how to configure Jenkins with the Generic Webhook Trigger plugin to automatically start builds whenever code is pushed to the develop branch of a Gitee (Git@OSC) repository, covering preparation, job setup, security settings, and webhook configuration.
Business Background
When developing with front‑back separation, the front end depends on backend APIs. Each API change often requires redeploying to the dev environment. In a typical Git workflow, develop and master branches are separate, and code merged to develop must be built manually.
Using Jenkins as the integration tool, each code merge still requires a manual build.
The goal is to automatically trigger a build when code is pushed to the develop branch. The common solution is to use a webhook (callback) that calls a configured HTTP address after a push.
This article demonstrates how to use the “Generic Webhook Trigger” plugin on the Gitee (Git@OSC) platform to achieve this.
Preparation
Assume you already have basic knowledge of Jenkins. Install the Generic Webhook Trigger plugin via “Manage Jenkins → Manage Plugins → Available”. After installation, restart Jenkins.
Project repository (private) on Gitee: https://git.oschina.net/xuliugen/dlt-server.git
Setup
1. Create a Job
For a Maven project, select the appropriate options as shown in the screenshot.
2. Configure the Job
Configure the following sections in order: General → Source Code Management → Build Triggers → Optional Filter → Build Environment → Pre Steps → Build → Post Steps → Build Settings → Post‑build Actions.
General
Source Code Management
Set the repository URL and credentials. Specify the branch to build (develop for development, otherwise master).
Build Triggers
Check “Generic Webhook Trigger”.
Optional Filter, Build Environment, Pre Steps
Build
Specify the root pom file and Maven goals. Example command to build the dev profile and skip tests:
clean install -Pdev -Dmaven.test.skip=true -e
Check “Run only if build succeeds”.
Post‑build Actions
Deploy to a Tomcat container (details omitted).
Save the configuration.
Configure Users and Security
In “Manage Jenkins → Manage Users”, create a user and obtain the API token.
In “Configure Global Security”, disable CSRF protection to allow webhook calls from Gitee.
Configure Gitee Webhooks
In the Gitee repository settings, add a webhook with a POST URL in the following format:
http:// : /generic-webhook-trigger/invoke?token=
Fill in the User ID, API Token, Jenkins IP, and port as shown in the screenshots.
Submit the webhook and click “Test” to verify that Jenkins starts the build.
All configuration is now complete.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
