Skip to main content

Automatically Marking Jenkins builds as keep forever

Comments

6 comments

  • Marlene Cote

    I have tried to get this code to work by fixing things like missing quotes and parenthesis, but I am having no luck.  Is someone available to help me with this?  I am learning groovy script, so I am probably making a novice mistake, but it would be nice for you to at least post working code if you are offering it.

    I believe this line is missing a quote and parenthesis.

    def envVarsMap = build.parent.builds[0].properties.get("envVarsonfig.putAll(envVarsMap)
    0
  • Dheeraj Reddy

    Curious if there is a way to automatically unmark jenkins builds that are marked as "Keep this build forever" ?

    1
  • Denys Digtiar

    Marlene: You are right about the missing syntax. Let us review the article.

    Pendridheeraj: `keepLog` method accepts a `boolean`. If you want to unmark a build pass it `false` instead or `true`.

    0
  • Dheeraj Reddy

    @Denys Digtiar: That makes sense..! Thanks a lot for the quick response :)

    0
  • Yingkit Yingkit

    @Denys Digtiar: Pipeline documentation says that keepLog is not writable for any builds but currentBuild, is there another way to modify that field for older builds in Pipeline? For example, is it possible to do the “Execute system Groovy script” method in a Jenkinsfile?

    1
  • Max Cascone

    @Yingkit Yingkit: use a script block in your declarative step to execute non-declarative syntax. 

    Also, I am curious if you ever found a way to un-set an older build as keepForever.

    https://jenkins.io/doc/book/pipeline/syntax/#script

    stage {
    steps {
    script {
    // non-declarative stuff here
    }
    }
    }
    0

Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.