Documentation 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.enhanced extends the basic 7-stage pipeline into a fully parameterized 15-stage workflow designed for multi-environment Java application delivery. It introduces pipeline parameters that operators set at build time, automatic versioning using a build-number/timestamp composite, grep-based security scanning for hardcoded secrets, per-environment Maven local repositories, deployment to either WildFly or JBoss via docker cp, version.properties injection into WAR files, versioned properties upload to Nexus, and a post-deployment HTTP verification step.
Pipeline Parameters
Target deployment environment. Selects which
config/environments/{env}/application.properties file is loaded and which Nexus repository receives artifacts. Accepted values: dev, staging, prod.Target application server container. Controls which Docker container name is used for
docker cp deployment and which Jenkins credential (wildfly-credentials or jboss-credentials) is resolved. Accepted values: wildfly, jboss.When
true, the Test stage is bypassed entirely via a when { expression { !params.SKIP_TESTS } } guard. Useful for hotfix deployments where test results are already known.When
true, both the SonarQube Analysis and Quality Gate stages are skipped. The Quality Gate stage shares the same when condition so neither runs nor blocks the pipeline.When
true, the Checkout or Extract stage unpacks source-code.zip from the workspace instead of running checkout scm. Enables deployment of applications that are not hosted in a Git repository.All 15 Stages
1. Initialize
1. Initialize
Prints pipeline metadata and computes a composite application version string that is used throughout all subsequent stages.
APP_VERSION takes the form {BUILD_NUMBER}-{yyyyMMdd-HHmmss}, for example 42-20251025-143022. This value is embedded in WAR files and uploaded to Nexus to make every artifact uniquely traceable.2. Read Build Config
2. Read Build Config
Reads
build-config.yml using readYaml and sets JAVA_VERSION, MAVEN_VERSION, and BUILD_TOOL environment variables. Identical in behavior to the basic Jenkinsfile, with fallback defaults when the file is absent.3. Load Environment Properties
3. Load Environment Properties
Reads the environment-specific
application.properties file for the selected ENVIRONMENT. The file is expected at config/environments/${ENVIRONMENT}/application.properties. A warning is printed if the file does not exist; the pipeline continues.4. Checkout or Extract
4. Checkout or Extract
Branches on the
FROM_ZIP parameter. When false, runs checkout scm. When true, unzips source-code.zip from the current workspace. The ZIP is expected to have been uploaded to the Jenkins workspace before the build is triggered.5. Security Scan - Password Detection
5. Security Scan - Password Detection
Scans all files under See Security Scanning for full pattern documentation and remediation guidance.
src/ for three categories of hardcoded secrets. A security-scan.txt report is written to the workspace root. The stage fails the build (exit 1) if any hardcoded password pattern is detected.6. Setup Maven Repository
6. Setup Maven Repository
Creates a per-environment local Maven repository directory at
.m2/repository-${ENVIRONMENT} inside the workspace. If config/environments/${ENVIRONMENT}/settings.xml exists, it is copied to .m2/settings.xml so environment-specific Nexus mirrors and server credentials are used for this build only.7. Build
7. Build
Builds the application using the
BUILD_TOOL set in stage 2, passing the per-environment Maven repository, app.version, and the selected ENVIRONMENT as system properties.8. Test
8. Test
Runs
mvn test against the environment-specific Maven repository. Skipped entirely when SKIP_TESTS is true. JUnit results are published with allowEmptyResults: true so the stage does not fail if no test reports exist.9. SonarQube Analysis
9. SonarQube Analysis
Runs
mvn sonar:sonar inside a withSonarQubeEnv('SonarQube') block. The project key includes the environment name (${JOB_NAME}-${ENVIRONMENT}) so each environment’s analysis is tracked separately in SonarQube. Skipped when SKIP_SONAR is true.10. Quality Gate
10. Quality Gate
Waits up to 5 minutes for SonarQube to return its Quality Gate result. If the gate status is not
OK, the pipeline is aborted immediately (abortPipeline: true). Shares the SKIP_SONAR guard with the analysis stage — if analysis was skipped, this stage is skipped too.11. Version and Tag Artifact
11. Version and Tag Artifact
Writes a The
version.properties file containing build metadata and injects it into the WAR file using jar uf. This makes provenance information available at runtime from inside the deployed application.version.properties keys written to each artifact:| Key | Example value |
|---|---|
VERSION | 42-20251025-143022 |
ENVIRONMENT | staging |
BUILD_NUMBER | 42 |
BUILD_DATE | 2025-10-25T14:30:22Z |
GIT_COMMIT | abc123def |
GIT_BRANCH | main |
BUILT_BY | Jenkins |
TARGET_SERVER | wildfly |
12. Deploy to Nexus
12. Deploy to Nexus
Uploads artifacts to the
maven-snapshots repository using mvn deploy. This stage runs on the main, master, and develop branches, or whenever the ENVIRONMENT parameter is dev or staging.13. Deploy to Application Server
13. Deploy to Application Server
Finds the WAR file in
target/, then uses docker cp to copy it into the deployment directory of the selected application server container (/opt/jboss/wildfly/standalone/deployments/). Runs only on main, master, and develop branches.14. Store Properties Version
14. Store Properties Version
Packages the
config/environments/${ENVIRONMENT} directory as a tarball named properties-${ENVIRONMENT}-${APP_VERSION}.tar.gz, adds a metadata.json file, and uploads the archive to Nexus using curl. This ensures that the exact configuration used for each build can be retrieved later.15. Post-Deployment Verification
15. Post-Deployment Verification
Waits 10 seconds after deployment to allow WildFly or JBoss to process the WAR file, then issues an HTTP request to the application endpoint to confirm it is accessible. Runs only on
main and master branches. A non-2xx response prints a warning but does not fail the build.Required Jenkins Credentials
Create all three credentials in Manage Jenkins → Credentials before running the enhanced pipeline:| Credentials ID | Type | Used by stage |
|---|---|---|
nexus-credentials | Username with password | Deploy to Nexus, Store Properties Version |
wildfly-credentials | Username with password | Deploy to Application Server (when TARGET_SERVER=wildfly) |
jboss-credentials | Username with password | Deploy to Application Server (when TARGET_SERVER=jboss) |
Using This Pipeline
Copy the file to your project
Copy
Jenkinsfile.enhanced to the root of your application repository and rename it Jenkinsfile (or keep the original name and set the Script Path accordingly).Configure a parameterized pipeline job
In Jenkins, create a new Pipeline item. Under Pipeline Definition select Pipeline script from SCM, point it to your repository, and set Script Path to
Jenkinsfile (or Jenkinsfile.enhanced if you kept the original name).Verify credentials exist
Confirm that
nexus-credentials, wildfly-credentials, and jboss-credentials are present in the Jenkins credential store before the first run.