groovy job DSL for triggering jenkins based on new release tags

时光总嘲笑我的痴心妄想 提交于 2019-12-24 10:24:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!