Comparing Jenkinsfiles for Test and Main Branches
Test Branch Jenkinsfile
In the test branch, the Jenkinsfile defines the following stages:- Maven Version
- Build
- Test
- Local Deployment
- Integration Testing
java -jar command for integration testing. In the test branch, the local deployment stage uses triple double quotes to allow for multiline string construction and pristine whitespace preservation:
/dev/null.
Main Branch Jenkinsfile
In the main branch, the Jenkinsfile is designed to build a production-ready pipeline. Notice that the Maven Version stage is omitted. Instead, the stages include:- Build
- Test
- Containerization
- Kubernetes Deployment
- Integration Testing
sleep) before issuing a test call.
Configuring a Parameterized Pipeline Job in Jenkins
Parameterizing your pipeline job enables a single job to run across branches and customize build options dynamically. Follow these steps in Jenkins:1. Create a New Pipeline Job
- In Jenkins Classic UI, click New Item.
- Name the job (e.g., “parameterized-pipeline-job”) and select the Pipeline project type.

2. Configure Source Control Management (SCM)
- Enter the repository URL for your pipeline script.
- Specify the branch. Initially, use the test branch by setting the script path to
Jenkinsfile.

3. Run a Quick Build
- Click Apply and then Build Now to validate the configuration.
- The run should display the build and test stages, along with the deployment phase. Use the Blue Ocean interface to view detailed logs.

4. Enable Parameterization
- In the job configuration, enable the This project is parameterized option.
- Add the following parameters to the job:



5. Parameterizing the Pipeline Script
Modify the Jenkinsfile to reference the defined parameters using the syntax${params.PARAMETER_NAME}. For example, update the Maven Version stage in the test branch as follows:
Remember to use double quotes in shell commands when referencing parameters to allow for proper variable substitution.
6. Triggering Parameterized Builds
- After committing the changes to the repository (for example, on the test branch), refresh the Jenkins job page. You should now see a Build with Parameters option.
- Clicking on Build with Parameters allows you to adjust default values (e.g., switching the branch to
testor setting the sleep time to5s) before triggering the build.

- Once the build starts, you can use Blue Ocean to review detailed logs.

7. Customizing for the Main Branch
Edit the Jenkinsfile on the main branch to incorporate parameters during integration testing:15s). The build log will reflect the updated parameters, and the integration testing stage will pause for the specified duration before proceeding.


Ensure that you update all necessary areas in your Jenkinsfiles to reflect the new parameterized approach. Missing a reference may lead to build inconsistencies.