Displaying Jenkins Pipeline Parameters on Build History

In Jenkins, it's crucial to see the parameters used in each pipeline build for debugging and auditing. The Groovy Postbuild plugin helps by letting you run a Groovy script after a build to show pipeline parameters in the build history. Jenkins is a free tool that automates building, testing, and deploying software, making development faster and more efficient with plugin customization. Pipelines use code to automate steps in software development, making workflows easier to manage; they come in Declarative and Scripted types. Parameters in pipelines let you input data when starting a pipeline, making them adaptable for different environments or features. Jenkins plugins add extra functions, connecting Jenkins with other tools like Git, running tests, and deploying applications.

Prerequisites

  • Jenkins installed and configured.
  • Basic understanding of Jenkins pipelines.
  • A Jenkins pipeline with parameters set up.
  • Groovy Postbuild Plugin installed.

Steps for the Task

  1. Install Jenkins and set up a basic pipeline project.
  2. Install the plug-in named “ Groovy Postbuild ”. https://plugins.jenkins.io/groovy-postbuild/
  3. In the pipeline configuration, select or tick the checkbox labeled "This project is parameterized."
  4. Jenkins
  5. Add a parameter, such as a string or choice.
  6. Jenkins
  7. Enter a name and default value for the parameter.
  8. Jenkins
  9. Click Save and Apply.
  10. Add the following lines to the pipeline Groovy file. In the post section, add the parameter to the history as a short text.
  11. post {
        always {
          script {
          manager.addShortText("${PARAMETER_NAME}")
          }
        }
    }
  12. Build the pipeline with your parameter value.
  13. Jenkins
  14. Check the pipeline build history to see the parameter value you passed in the pipeline.
  15. Jenkins

It indicates I passed the parameter 'branch' as 'master'.

Conclusion

By using the Groovy Postbuild plugin, you can make pipeline parameters more visible in Jenkins build history. This helps you better manage and fix issues in your CI/CD pipelines. Follow the steps in this guide to set up and personalize your Jenkins pipelines with post-build scripts.

If you have any comments or questions, feel free to ask me on LinkedIn.