How to Configure Jenkins for Maven Builds Across Multiple Environments
This guide explains how to set up Jenkins to run Maven builds for different environments (dev, beta, prod), including commands to skip tests, deploy to Nexus, and specify profile parameters, with screenshots illustrating the correct configuration to avoid common errors.
In projects with multiple development, beta, and production environments, parameters such as resource, resource.beat, resource.dev, and resource.prod are used to differentiate settings.
Typical Maven commands for these scenarios are:
mvn clean install -Dmaven.test.skip=true
mvn deploy -Dmaven.test.skip=true
mvn clean install -Pdev -Dmaven.test.skip=true
When Jenkins runs without explicit parameters, it defaults to the resource profile and does not build for the specific dev, beta, or prod profiles.
To configure Jenkins (v2.46.1) to use the desired profile, set the “Goals and options” field with the Maven goals only (do not prepend mvn). The correct entry looks like:
clean install -Pdev -Dmaven.test.skip=true
Providing the full command with mvn in this field will cause an error, as shown in the screenshot below.
After setting the correct parameters, the project builds successfully.
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.
