How do I use Jenkins Pipeline properties step?

后端 未结 2 1690
天涯浪人
天涯浪人 2020-12-05 12:34

I am studying capabilities of Jenkins Pipeline:Multibranch. It is said that a recently introduced properties step might be useful there, but I can\'t catch how

相关标签:
2条回答
  • 2020-12-05 13:33

    Using properties with explicit method syntax will work, i.e.:
    properties( [ ... ] ) rather than properties [ ... ]

    Alternatively, it will work without if you specify the parameter name, e.g.:

    properties properties: [ ... ]
    

    For example defining three properties is as easy as :

    properties([
      parameters([
        string(name: 'submodule', defaultValue: ''),
        string(name: 'submodule_branch', defaultValue: ''),
        string(name: 'commit_sha', defaultValue: ''),
      ])
    ])
    
    /* Accessible then with : params.submodule, params.submodule_branch...  */
    
    0 讨论(0)
  • 2020-12-05 13:33

    Multiple choice in Jenkins scripted pipeline

    properties([
      parameters([
            choice(choices: 'sprint_6\nsprint_7\nsprint_8\nSprint_9', description: 'Select branch to Build', name: 'Branch'),
            choice(choices: 'No\nYes', , name: 'choice2'),
            choice(choices: 'No\nYes', name: 'choice3')
      ])
    ])
    
    0 讨论(0)
提交回复
热议问题