[JIRA] (JENKINS-44679) need to support script inside options

6 views
Skip to first unread message

jnord@cloudbees.com (JIRA)

unread,
Sep 18, 2018, 10:32:02 AM9/18/18
to jenkinsc...@googlegroups.com
James Nord commented on Improvement JENKINS-44679
 
Re: need to support script inside options

Andrew Bayer has confirmed that the following works now and is now supported.

pipeline {
    options {
        buildDiscarder(logRotator(numToKeepStr: "${env.CHANGE_ID == null ? '100' : '5'}"))
    }
}
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

andrew.bayer@gmail.com (JIRA)

unread,
Nov 16, 2018, 1:32:01 PM11/16/18
to jenkinsc...@googlegroups.com
Change By: Andrew Bayer
Status: Open Fixed but Unreleased
Resolution: Won't Fix

awiddersheim@hotmail.com (JIRA)

unread,
Jun 25, 2019, 9:06:02 AM6/25/19
to jenkinsc...@googlegroups.com
Andrew Widdersheim commented on Improvement JENKINS-44679
 
Re: need to support script inside options

I have a similar need here but a bit more complex than the original reporter. I see that this issue is closed but hopefully we can re-examine the use case. I can also make a new issue.

In my case I'd much rather omit buildDiscarder(). Also the original solution doesn't really work with things like disableConcurrentBuilds(). For example, it is not possible AFAIK to do something like:
pipeline {
options

{ disableConcurrentBuilds(env.FOO ? true : false) }

}
Either way I'd much prefer to do something like this:

pipeline { 
    options {
        script {
            if (env.FOO) { 
                buildDiscarder logRotator(daysToKeepStr: '30')
                disableConcurrentBuilds()
            } 
        }
    } 
}

awiddersheim@hotmail.com (JIRA)

unread,
Jun 25, 2019, 9:10:03 AM6/25/19
to jenkinsc...@googlegroups.com
Andrew Widdersheim edited a comment on Improvement JENKINS-44679
I have a similar need here but a bit more complex than the original reporter. I see that this issue is closed but hopefully we can re-examine the use case. I can also make a new issue.

In my case I'd much rather omit {{buildDiscarder()}}. Also the original solution doesn't really work with things like {{disableConcurrentBuilds()}}. For example, it is not possible AFAIK to do something like:
{code:java}
pipeline \ {
    options {


        disableConcurrentBuilds(env.FOO ? true : false)

    }
}
{code}
Either way I'd much prefer to do something like this:
{code:java}

pipeline {
    options {
        script {
            if (env.FOO) {
                buildDiscarder logRotator(daysToKeepStr: '30')
                disableConcurrentBuilds()
            }
        }
    }
}{code}
Reply all
Reply to author
Forward
0 new messages