This will add text to the specific job on the summary page of the classic UI. The text does not show up on the BlueOcean UI.

script {
   manager.addShortText("Some text")
   manager.addShortText("\ntext")

   manager.addShortText("same line", "black", "lightgreen", "0px", "white")
   manager.addShortText(text, foreground_color, background_color, border_width, border_color)
}

For the manager object to exists we need to install the Groovy Postbuild Plugin

examples/jenkins/manager_addShortText.Jenkinsfile

  1. pipeline {
  2. agent {
  3. label 'master'
  4. }
  5. parameters {
  6. string(name: 'text', defaultValue: 'Some Text', description: 'Text')
  7. string(name: 'foreground_color', defaultValue: 'black', description: 'Foreground')
  8. string(name: 'background_color', defaultValue: 'lightgreen', description: 'Background')
  9. string(name: 'border_size', defaultValue: '5px', description: 'Border size')
  10. string(name: 'border_color', defaultValue: 'yellow', description: 'Border color')
  11. }
  12.  
  13. stages {
  14. stage('Check disk usage') {
  15. steps {
  16. script {
  17. manager.addShortText(
  18. params.text,
  19. params.foreground_color,
  20. params.background_color,
  21. params.border_size,
  22. params.border_color
  23. )
  24. currentBuild.description = "Foreground: ${foreground_color}<br>"
  25. currentBuild.description += "Background: ${background_color}<br>"
  26. currentBuild.description += "Border size: ${params.border_size}<br>"
  27. currentBuild.description += "Border color: ${params.border_color}"
  28.  
  29. }
  30. }
  31. }
  32. }
  33. }
  34.