Declarative pipeline "when" tag is pushed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Declarative pipeline "when" tag is pushed

Lynn Lin-2
HI ,All,

 i followed with page https://wiki.jenkins.io/display/JENKINS/GitHub+Branch+Source+Plugin to enable tag will trigger a new build then the questions comes 

How can I use "when" in declarative pipeline to do something like deployment when a new tag is pushed to remote repository


stage('Example Deploy') {
            when {
                branch 'production' // here how we can use tag as condition 
            }
            steps {
                echo 'Deploying'
            }
        }



"
  • When used with the Branch API Plugin, tags will show up as a new category. The default configuration of Branch API will not trigger builds for tags automatically. 

    This is by design, as one of the use-cases for tag discovery is to use the tag job to perform deployment. If tags were built automatically, given that the order in which the tag jobs actually execute is undefined, the automatic build could cause significant issues. Branch API does provide a mechanism to control what gets built automatically (known as the BranchBuildStrategy) but that cannot be configured until you have at least one extension plugin that provides a BranchBuildStrategy

    If you want tags to build automatically, you will need an extension plugin for Branch API that implements at least one BranchBuildStrategy, see AngryBytes/jenkins-build-everything-strategy-plugin for a prototype example of such an extension plugin.


Thanks
Lynn

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7f91e19e-1e8f-45a4-8a36-d5d620867979%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Declarative pipeline "when" tag is pushed

Steven Foster
I think you can get that with this:

when {
    expression
{
        env
.
TAG_NAME != null
   
}

}

You get the env.TAG_NAME from the branch api when it's a tag build.
A shortcut would be helpful, I suggested it here https://issues.jenkins-ci.org/browse/JENKINS-48523


On Wednesday, December 20, 2017 at 7:12:44 AM UTC, Lynn Lin wrote:
HI ,All,

 i followed with page <a href="https://wiki.jenkins.io/display/JENKINS/GitHub+Branch+Source+Plugin" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FGitHub%2BBranch%2BSource%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFlYa3trqaoi8L8Y2blTyXgF8kAtg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FGitHub%2BBranch%2BSource%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFlYa3trqaoi8L8Y2blTyXgF8kAtg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/GitHub+Branch+Source+Plugin to enable tag will trigger a new build then the questions comes 

How can I use "when" in declarative pipeline to do something like deployment when a new tag is pushed to remote repository


stage('Example Deploy') {
            when {
                branch 'production' // here how we can use tag as condition 
            }
            steps {
                echo 'Deploying'
            }
        }



"
  • When used with the <a href="https://wiki.jenkins.io/display/JENKINS/Branch+API+Plugin" style="color:rgb(75,117,139)" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FBranch%2BAPI%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHYgz-0L6GUzi-OYNeG0VEc63EbAQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FBranch%2BAPI%2BPlugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHYgz-0L6GUzi-OYNeG0VEc63EbAQ&#39;;return true;">Branch API Plugin, tags will show up as a new category. The default configuration of Branch API will not trigger builds for tags automatically. 

    This is by design, as one of the use-cases for tag discovery is to use the tag job to perform deployment. If tags were built automatically, given that the order in which the tag jobs actually execute is undefined, the automatic build could cause significant issues. Branch API does provide a mechanism to control what gets built automatically (known as the BranchBuildStrategy) but that cannot be configured until you have at least one extension plugin that provides a BranchBuildStrategy

    If you want tags to build automatically, you will need an extension plugin for Branch API that implements at least one BranchBuildStrategy, see <a href="https://github.com/AngryBytes/jenkins-build-everything-strategy-plugin" rel="nofollow" style="color:rgb(75,117,139)" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FAngryBytes%2Fjenkins-build-everything-strategy-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFZ4N0SLh8qcULAx1-Awsiz6i59vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FAngryBytes%2Fjenkins-build-everything-strategy-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFZ4N0SLh8qcULAx1-Awsiz6i59vw&#39;;return true;">AngryBytes/jenkins-build-everything-strategy-plugin for a prototype example of such an extension plugin.


Thanks
Lynn

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9db42595-b6ad-4496-bf3f-0cd2db6c6ae2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Declarative pipeline "when" tag is pushed

Lynn Lin-2

Steven Foster <[hidden email]>于2017年12月21日 周四上午9:54写道:
I think you can get that with this:

when {
    expression
{
        env
.
TAG_NAME != null
   
}

}


Thanks,it works

You get the env.TAG_NAME from the branch api when it's a tag build.
A shortcut would be helpful, I suggested it here https://issues.jenkins-ci.org/browse/JENKINS-48523
This is even great 

On Wednesday, December 20, 2017 at 7:12:44 AM UTC, Lynn Lin wrote:
HI ,All,

 i followed with page https://wiki.jenkins.io/display/JENKINS/GitHub+Branch+Source+Plugin to enable tag will trigger a new build then the questions comes 

How can I use "when" in declarative pipeline to do something like deployment when a new tag is pushed to remote repository


stage('Example Deploy') {
            when {
                branch 'production' // here how we can use tag as condition 
            }
            steps {
                echo 'Deploying'
            }
        }



"
  • When used with the Branch API Plugin, tags will show up as a new category. The default configuration of Branch API will not trigger builds for tags automatically. 

    This is by design, as one of the use-cases for tag discovery is to use the tag job to perform deployment. If tags were built automatically, given that the order in which the tag jobs actually execute is undefined, the automatic build could cause significant issues. Branch API does provide a mechanism to control what gets built automatically (known as the BranchBuildStrategy) but that cannot be configured until you have at least one extension plugin that provides a BranchBuildStrategy

    If you want tags to build automatically, you will need an extension plugin for Branch API that implements at least one BranchBuildStrategy, see AngryBytes/jenkins-build-everything-strategy-plugin for a prototype example of such an extension plugin.


Thanks
Lynn

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/D0jCrBe-7A0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9db42595-b6ad-4496-bf3f-0cd2db6c6ae2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPgpnMS2mtKrxLBw0wQCxVis06tVQ5cwkWAcu8rJ4vvrMDedtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.