问题
I came across this setting for jenkins job to trigger jenkins when a new release tag is created on git repo like github but wondering what the equivalent is for groovy jobs DSL script.
https://mohamicorp.atlassian.net/wiki/spaces/DOC/pages/136740885/Triggering+Jenkins+Based+on+New+Tags
Here is also link to same question asked but without the groovy job DSL script version jenkins trigger build if new tag is released
How can one know how to write groovy job DSL scripts based on jenkins job settings? I am yet to find a great documentation that explains the login when it comes to converting jenkins jobs to job DSL scriprs
Thanks
回答1:
The built in Jenkins pipeline syntax tool should be able to help you create the script block for any of the plugins that you wish to use with the DSL. Any pipeline job will have a link for it on the left hand side.
This is roughly what it will look like after you enter in all your information (ie: repo location, branches, authentication). The part that you need is the refspec if you are on the syntax page it will be under the advanced button.
checkout([$class: 'GitSCM', branches: [[name: '**']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'yourAuthHere', refspec: '+refs/tags/*:refs/remotes/origin/tags/*', url: 'yourGitRepoLocationHere']]])
来源:https://stackoverflow.com/questions/54930947/groovy-job-dsl-for-triggering-jenkins-based-on-new-release-tags