TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/infra-neo/CICD/llms.txt
Use this file to discover all available pages before exploring further.
Jenkinsfile in the project root defines a declarative Jenkins pipeline that automates the full build-and-publish lifecycle for Java applications. On every run it reads build-config.yml to determine Java and Maven versions, checks out source code, compiles and packages with Maven, executes tests and publishes JUnit results, submits code to SonarQube for quality analysis, waits for the Quality Gate verdict, and — on protected branches — deploys artifacts to the Nexus snapshot repository.
Pipeline Overview
| Stage | What it does |
|---|---|
| Read Build Config | Reads build-config.yml with readYaml; sets JAVA_VERSION, MAVEN_VERSION, and BUILD_TOOL environment variables for all downstream stages |
| Checkout | Runs checkout scm to retrieve source code from the SCM configured on the Jenkins job |
| Build | Runs mvn clean install -DskipTests for standard Maven projects, or mvn clean package -DskipTests when BUILD_TOOL is mule-maven-plugin |
| Test | Runs mvn test and publishes JUnit results from **/target/surefire-reports/*.xml via the JUnit plugin |
| SonarQube Analysis | Executes mvn sonar:sonar inside a withSonarQubeEnv('SonarQube') block so the plugin automatically injects the server URL and authentication token |
| Quality Gate | Calls waitForQualityGate abortPipeline: true inside a 5-minute timeout; aborts the pipeline if the gate fails |
| Deploy to Nexus | Runs mvn deploy targeting maven-snapshots; only executes on main, master, or develop branches |
Complete Jenkinsfile
Required Jenkins Credentials
Before running the pipeline, create the following credential in Manage Jenkins → Credentials:| Credentials ID | Type | Used by |
|---|---|---|
nexus-credentials | Username with password | Deploy to Nexus stage — supplies NEXUS_USER and NEXUS_PASS to the mvn deploy command |
Creating the Pipeline Job
Open Jenkins
Navigate to Jenkins at http://localhost:8080 and log in.
Configure the pipeline definition
Scroll to the Pipeline section. Under Definition, select Pipeline script from SCM. Set SCM to Git and enter your repository URL.
Set the script path
In the Script Path field enter
Jenkinsfile (the default). Leave all other fields at their defaults unless your repository requires specific credentials.Post-Build Actions
Thepost block runs after every pipeline execution regardless of outcome:
| Condition | Action |
|---|---|
success | Prints Pipeline completed successfully! to the build log |
failure | Prints Pipeline failed! to the build log |
always | Calls cleanWs() to delete the workspace and free disk space on the Jenkins agent |
For the full parameterized pipeline with environment selection, WildFly/JBoss deployment, per-environment Maven repositories, artifact versioning, and automated security scanning, see the Enhanced Pipeline documentation which covers
Jenkinsfile.enhanced.