Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50442

Adding removeBadge(icon) and removeAllBadges() methods to remove existing badges

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • badge-plugin
    • jenkins 2.113
      badge-plugin 1.2

      The new DSL addBadge() allow to create a new badge directly from the pipeline.

      How to remove it later on ? In our workflow, there are several pauses waiting for user input, and at each stage we are displaying a different icons (removing previous one and adding a different one).

      Here a workaround:

      def removeBadges(RunWrapper build, String icon = null) {
       List<Action> actions = build.getRawBuild().getActions()
       List<BuildBadgeAction> badgeActions = build.getRawBuild().getActions(BuildBadgeAction.class)
       for(BuildBadgeAction action : badgeActions) {
        if (icon == null || action.iconPath == icon) {
         actions.remove(action)
        }
       }
      }
      

      Would need a removeBadge(icon) and removeAllBadges() methods to do it directly in the pipeline.
       

            bakito Marc Brugger
            jguigui Jean-Paul G
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: