"Keep build forever" step is not a common build step in Jenkins as it is provided by the promoted build plugins. The current DSL support delegates all the actions block to StepContext which will not have the "Keep build forever" action.

          [JENKINS-37521] Add keep build forever action to Job DSL

          Oleg Nenashev added a comment -

          daspilker I am not sure this request is specific to the Promoted Builds plugin. Should it be considered as a general feature?

          Oleg Nenashev added a comment - daspilker I am not sure this request is specific to the Promoted Builds plugin. Should it be considered as a general feature?

          "Keep build forever" is a "post-build action" (aka publisher) and it's already supported by the Automatically Generated DSL:

          job('example') {
            publishers {
              keepBuildForeverAction()
            }
          }
          

          oleg_nenashev: IMHO this ticket can be closed.

          Daniel Spilker added a comment - "Keep build forever" is a "post-build action" (aka publisher) and it's already supported by the Automatically Generated DSL : job( 'example' ) { publishers { keepBuildForeverAction() } } oleg_nenashev : IMHO this ticket can be closed.

          Lonnie Brownell added a comment - - edited

          We've got Jenkins 1.585 and 2.46.2, both of which have the promoted build plugins installed and use the Keep Alive action in promotion steps.

          However, I have a case now where I want to mark some builds keep forever based on conditions within the job. The Keep Forever action is only available in promotion actions, not in post-build actions (or build actions), so reality is not matching Daniel Spilker's theory.  Is there something amiss with our configuration?

          However, even if it were available  as a post-build action, I still wouldn't be able to use it directly, as there is no conditional action in post-build.  If it were available as a build action, I could use it there.  Instead, I reckon it's a REST call  wrapped in a condition.

          EDIT:  Or this:  https://support.cloudbees.com/hc/en-us/articles/218762207-Automatically-Marking-Jenkins-builds-as-keep-forever

          Lonnie Brownell added a comment - - edited We've got Jenkins 1.585 and 2.46.2, both of which have the promoted build plugins installed and use the Keep Alive action in promotion steps. However, I have a case now where I want to mark some builds keep forever based on conditions within the job. The Keep Forever action is only available in promotion actions, not in post-build actions (or build actions), so reality is not matching Daniel Spilker's theory.  Is there something amiss with our configuration? However, even if it were available  as a post-build action, I still wouldn't be able to use it directly, as there is no conditional action in post-build.  If it were available as a build action, I could use it there.  Instead, I reckon it's a REST call  wrapped in a condition. EDIT:  Or this:   https://support.cloudbees.com/hc/en-us/articles/218762207-Automatically-Marking-Jenkins-builds-as-keep-forever

            Unassigned Unassigned
            ceilfors Wisen Tanasa
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: