Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am searching a way to define pipeline options based on JOB_NAME in declarative pipeline

pipeline {
    agent any
    
    options {
        when { expression { return env.JOB_NAME.equals('test_job') } }       <----------
                    
        disableConcurrentBuilds()
    }

and I am getting the error

11:23:15  WorkflowScript: 39: Options definitions cannot have blocks @ line 39, column 9.
11:23:15             when { expression { return env.JOB_NAME.equals('test_job') } }

Any workaround to achieve this? Thank you


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
602 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...