Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 views
in Technique[技术] by (71.8m points)

jenkins - Jenkinsfile pipeline option: when equivalent

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

question from:https://stackoverflow.com/questions/65670779/jenkinsfile-pipeline-option-when-equivalent

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

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...