[JENKINS-62130] Simplify Pipeline authoring with symbols - #1373
Conversation
basil
left a comment
There was a problem hiding this comment.
Very nice! Some optional feedback for your consideration: consider using the camel case convention defined by Google which would result in e.g. gitScm and gitLfsPull over gitSCM and gitLFSPull.
Arguments in favor of Google convention: highly logical and deterministic.
Arguments against Google convention: other Jenkins classes and symbols don't follow the Google convention, diminishing the value of following the Google convention in just this one place (and perhaps even resulting in a jarring difference in conventions, if the existing Jenkins style could even be called a convention).
Anyway, no strong feeling from my side, and certainly happy with the improvement as-is.
Thanks for the comment. The Pipeline Multibranch plugin follows the Google convention with |
Git plugin 5.0 will require Java 11 and will add symbols to improve the Pipeline syntax editing experience. The test being modified in this pull request checks the specific syntax of the Pipeline snippet syntax generator. Adapt the test to check for current syntax with git plugin 4.x releases and for new syntax with any other releases. jenkinsci/git-client-plugin#939 is the git client plugin pull request that prepares git client plugin 4.0.0. It will require Java 11 and will upgrade from JGit 5.13.1 to JGit 6.4.0. jenkinsci/bom#1619 is the bom draft pull request that confirms git client plugin 4.0.0 pre-release works in the plugin bom. jenkinsci/git-plugin#1367 is the git plugin pull request that prepares git plugin 5.0.0. It will require Java 11. jenkinsci/bom#1624 is the bom draft pull request that tests git plugin 5.0.0 works in the plugin bom. jenkinsci/git-plugin#1373 is the git plugin pull request that relies on jenkinsci/git-plugin#1367 and adds symbols to the git plugin. jenkinsci/bom#1625 is the bom draft pull request that tests git plugin 5.0.0 with added symbols works in the plugin bom. It detected this test failure when run with git plugin 5.0.0 pre-release.
Pipeline authoring with the git plugin has not been using the symbol
facility that is used elsewhere in Jenkins.
Previously, a Pipeline checkout might look like this:
checkout([$class: 'GitSCM',
userRemoteConfigs: [[url: 'https://github.com/jenkinsci/git-plugin.gi' ]],
branches: [[name: 'master']],
extensions: [[$class: 'CloneOption', noTags: true, timeout: 3],
[$class: 'LocalBranch', localBranch: branch],
],
])
With the addition of symbols, the earlier Pipeline checkout continues
to be supported, but it can also be written as:
checkout scmGit(
userRemoteConfigs: [[url: 'https://github.com/jenkinsci/git-plugin.gi' ]],
branches: [[name: 'master']],
extensions: [cloneOption(noTags: true, timeout: 3),
localBranch('master')
],
)
The symbols make it easier to read and easier to understand.
Change includes updated documentation with Pipeline examples and
screenshots taken with Jenkins 2.375.1.
Thanks to Karl Shultz for starting the work on this improvement.
e4c66d7 to
e752625
Compare
Clearer name and does not embed Microsoft in the symbol value
JENKINS-62130 Simplify Pipeline authoring with symbols
Pipeline authoring is easier from the Pipeline snippet syntax generator when symbols are provided by the plugin.
Special thanks to Karl Schultz for starting this project.
Checklist
Types of changes
Further comments
A number of questions will arise as part of the testing and exploration of this pull request.
Configuration as code changes
Several configuration as code symbols have been made obsolete, with a newer symbol as the preferred value. Those symbols include:
Configuration as Code obsolete file format:
Known issues in progress
gitand needs to be changed toscmGit. See the before line and the after line for the example.[$class: 'SubmoduleOption', depth: 1, shallow: true]it should besubmodule(depth: 1, shallow: true). Done in 89f648aPending investigation
submodule(timeout:null)when null is the default value for timeout, it should offersubmodule()(won't do)