groovy job DSL for triggering jenkins based on new

2019-07-25 05:56发布

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

enter image description here

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条回答
家丑人穷心不美
2楼-- · 2019-07-25 06:18

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']]])
查看更多
登录 后发表回答