Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58112

Triggering multibranch pipeline from jira-trigger-plugin

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

       
      I have Jenkins Mutibranch pipeline. I want to integrate my Jira with one of multibranch project. I have installed the JIRA Trigger Plugin and configured Webhook in Jira. however, when I checked in my Jenkins job configuration,  its does not show me the Build when an issue is updated in JIRA but it shows when I go to View Configuration in the particular branch. it allows me to select the Build when an issue is updated in JIRA but there is no option to save the changes. I know this might be a reason the option is view only and the parameters getting from jenkinsfile. but how can I get this work when using mutibranch pipeline in Jenkins?

      1. Is anyone configured JIRA Trigger Plugin with Jenkins mutibranch project where using Jenkinsfile? and what is the correct way of integrating this?
      1. Should I do some coding in the Jenkins file to get this done?

        Attachments

          Activity

          Hide
          ceilfors Wisen Tanasa added a comment -

          Thanks for filing this issue. This is not a tested feature. Can you help me understand what are you trying to achieve:

          • When a there is change in JIRA, which branch are you expecting to build?
          • What are you expecting to be there but not there to make this functionality to work?

          When I read the documentation for multi branch pipeline, it seems like the only trigger that makes sense is a source control system like Git, that has branches.

          Show
          ceilfors Wisen Tanasa added a comment - Thanks for filing this issue. This is not a tested feature. Can you help me understand what are you trying to achieve: When a there is change in JIRA, which branch are you expecting to build? What are you expecting to be there but not there to make this functionality to work? When I read the documentation for multi branch pipeline, it seems like the only trigger that makes sense is a source control system like Git, that has branches .
          Hide
          hhkkss hhkkss added a comment - - edited

          Thanks for the response. please see below comments. 

          • When there is change in JIRA, which branch are you expecting to build?

          In our Multibranch pipeline, most probably have two branches named, development and release. we handle CD only for release branch. but this is not the case, my problem is whether the Jira-trigger-plugin supports for Multibranch pipeline jobs.

           

          • What are you expecting to be there but not there to make this functionality to work?

          As I understood from [this|https://github.com/jenkinsci/jira-trigger-plugin], Jira-trigger-plugin allows when the issues comment added/updated or stage changed, which notify Jenkins through Webhook call, so Jenkins build can be configured to trigger builds by selecting the checkbox under Job configurations with below options. 

          My question is, can we obtain the same feature for Jenkins Multibranch pipeline jobs as well? because when I go to job configuration in my Multibranch pipeline Job, I don't see below two options under build triggers while I already installed the plugin and restarted the Jenkins service. but these options is there for other common pipeline jobs. only Multibranch pipeline jobs does not contains these options. 

          Build when a comment is added to Jira

          Build when an issue updated in JIRA

           

          I hope now days most of DevOps guys are using Jenkins Multibranch pipeline plugin for their CI/CD. hence, this is really nice if the Jira-trigger-plugin support for Multibranch pipeline as well. 

           

          Show
          hhkkss hhkkss added a comment - - edited Thanks for the response. please see below comments.  When there is change in JIRA, which branch are you expecting to build? In our Multibranch pipeline, most probably have two branches named,  development and release. we handle CD only for release branch. but this is not the case, my problem is whether the  Jira-trigger-plugin  supports for Multibranch pipeline jobs.   What are you expecting to be there but not there to make this functionality to work? As I understood from [this| https://github.com/jenkinsci/jira-trigger-plugin ],  Jira-trigger-plugin allows when the issues comment added/updated or stage changed, which notify Jenkins through Webhook call, so Jenkins build can be configured to trigger builds by selecting the checkbox under Job configurations with below options.  My question is, can we obtain the same feature for Jenkins Multibranch pipeline jobs as well? because when I go to job configuration in my Multibranch pipeline Job, I don't see below two options under build triggers while I already installed the plugin and restarted the Jenkins service. but these options is there for other common pipeline jobs. only Multibranch pipeline jobs does not contains these options.  Build when a comment is added to Jira Build when an issue updated in JIRA   I hope now days most of DevOps guys are using Jenkins Multibranch pipeline plugin for their CI/CD. hence, this is really nice if the  Jira-trigger-plugin  support for Multibranch pipeline as well.   
          Hide
          ceilfors Wisen Tanasa added a comment -

          Thanks. I understand your problem that this is not supported at the moment.

          What I'm trying to understand better is the behaviour of jira-trigger-plugin that you're expecting if this plugin is supporting multibranch pipeline. So if you have development and release branch in your multibranch pipeline job, which branch would the plugin trigger? For example in git trigger, if there is a change in development branch, only development job is triggered. I'm not sure what are you expecting when multibranch pipeline job is configured with jira-trigger-plugin, trigger all branches build?

          Probably you can try given when then format.

          Show
          ceilfors Wisen Tanasa added a comment - Thanks. I understand your problem that this is not supported at the moment. What I'm trying to understand better is the behaviour of jira-trigger-plugin that you're expecting if this plugin is supporting multibranch pipeline. So if you have development and release branch in your multibranch pipeline job, which branch would the plugin trigger? For example in git trigger, if there is a change in development branch, only development job is triggered. I'm not sure what are you expecting when multibranch pipeline job is configured with jira-trigger-plugin, trigger all branches build? Probably you can try given when then format.
          Hide
          hhkkss hhkkss added a comment -

          My requirement is to trigger release branch as i would require continues delivery when the developers merged their code with the release branch. 

          Lets say my pipeline must be triggered like below:

                    Lets say I have Jira project named "Project1" and has issue ID named "Issue-1", so whenever, "Issue-1" comes to "Deploy in SIT" stage in my workflow, it must be sent an Webhook call to my Jenkins API and from there I should able to run the matching branch in my Multibranch pipeline job.

          In my Jenkins pipeline, I have SCM checkout, Build, unit testing, packaging, SIT deployment, UAT deployment, PROD deployment.

          Note, in my scenario I will deploy into SIT only from release branch and this can be continue to UAT and PROD deployments if the proper approval is there. but none of deployment triggers from development branch, instead, all development branch triggers will be stopped at unit testing stage as I have defined WHEN condition in Jenkinsfile for other stages after unit testing, which WHEN condition should match "BRANCH = release".

          It would be nice to have "pattern matching feature" in Multibranch Job configuration so the we can put some branch pattern and allow to trigger any branch which matches that pattern.   

          Show
          hhkkss hhkkss added a comment - My requirement is to trigger release branch as i would require continues delivery when the developers merged their code with the release branch.  Lets say my pipeline must be triggered like below:           Lets say I have Jira project named "Project1" and has issue ID named "Issue-1", so whenever, "Issue-1" comes to "Deploy in SIT" stage in my workflow, it must be sent an Webhook call to my Jenkins API and from there I should able to run the matching branch in my Multibranch pipeline job. In my Jenkins pipeline, I have SCM checkout, Build, unit testing, packaging, SIT deployment, UAT deployment, PROD deployment. Note, in my scenario I will deploy into SIT only from release branch and this can be continue to UAT and PROD deployments if the proper approval is there. but none of deployment triggers from development branch, instead, all development branch triggers will be stopped at unit testing stage as I have defined WHEN condition in Jenkinsfile for other stages after unit testing, which WHEN condition should match "BRANCH = release". It would be nice to have "pattern matching feature" in Multibranch Job configuration so the we can put some branch pattern and allow to trigger any branch which matches that pattern.   
          Hide
          ceilfors Wisen Tanasa added a comment -

          Thanks for the detailed use case.

          A pattern matching won't suffice as you might want to trigger different workflow to different branches i.e. "Deploy in SIT" for "release branch", "Deploy in UAT" for "uat branch" (example), etc.

          Perhaps your best bet here is to get your branch triggered by an upstream project:

          To be honest I'm not really sure if Multibranch job is really appropriate in your use case either, what I'm hearing is:

          • release branch: sit deployment, uat deployment, prod deployment
          • other branches: scm checkout, build, unit testing, packaging

          It sounds like they are an entirely different jobs that sharing one Jenkinsfile might not be appopriate?

          Show
          ceilfors Wisen Tanasa added a comment - Thanks for the detailed use case. A pattern matching won't suffice as you might want to trigger different workflow to different branches i.e. "Deploy in SIT" for "release branch", "Deploy in UAT" for "uat branch" (example), etc. Perhaps your best bet here is to get your branch triggered by an upstream project: deploy in uat job: configured with jira-trigger-plugin multibranch pipeline job: configured with upstream trigger to "deploy in uat job" (see:  https://stackoverflow.com/questions/36825103/jenkins-trigger-multi-branch-pipeline-on-upstream-change ) To be honest I'm not really sure if Multibranch job is really appropriate in your use case either, what I'm hearing is: release branch: sit deployment, uat deployment, prod deployment other branches: scm checkout, build, unit testing, packaging It sounds like they are an entirely different jobs that sharing one Jenkinsfile might not be appopriate?
          Hide
          hhkkss hhkkss added a comment - - edited

          I agree with you on following points. but the thing is, in that case I have to create individual upstream projects for all my pipeline projects. . or let me know if there is any workaround to manage from single upstream job.  

          Perhaps your best bet here is to get your branch triggered by an upstream project:

           

          Regarding the below comment, what I was trying to tell you is my pipeline is same for all the branches in the project. but it has WHEN condition's defined already. thus, deployment handle only from release branch. meaning, development branch is only to commit day to day changes. whenever, developers are ready to move the changes into SIT, then they have to merge the changes into release branch and then only entire pipeline is triggered. any triggers from development branch will not handle any deployment and it will run the build and unit testing only, so developers know that they do not have any compilation errors on the code.

           

          its simply like below:

           

           { stage ('SIT Deployment'){
            when { branch 'release' } 
                 steps {    
                    script {"my deployment"
          .....
           
          

           

          To be honest I'm not really sure if Multibranch job is really appropriate in your use case either, what I'm hearing is:

           

          • release branch: sit deployment, uat deployment, prod deployment
          • other branches: scm checkout, build, unit testing, packaging

          It sounds like they are an entirely different jobs that sharing one Jenkinsfile might not be appopriate?

          Show
          hhkkss hhkkss added a comment - - edited I agree with you on following points . but the thing is, in that case I have to create individual upstream projects for all my pipeline projects. . or let me know if there is any workaround to manage from single upstream job.   Perhaps your best bet here is to get your branch triggered by an upstream project: deploy in uat job: configured with jira-trigger-plugin multibranch pipeline job: configured with upstream trigger to "deploy in uat job" (see:  https://stackoverflow.com/questions/36825103/jenkins-trigger-multi-branch-pipeline-on-upstream-change )   Regarding the below  comment, what I was trying to tell you is my pipeline is same for all the branches in the project. but it has WHEN condition's defined already. thus, deployment handle only from release branch. meaning, development branch is only to commit day to day changes. whenever, developers are ready to move the changes into SIT, then they have to merge the changes into release branch and then only entire pipeline is triggered. any triggers from development branch will not handle any deployment and it will run the build and unit testing only, so developers know that they do not have any compilation errors on the code.   its simply like below:   { stage ( 'SIT Deployment' ){ when { branch 'release' } steps {    script { "my deployment" .....   To be honest I'm not really sure if Multibranch job is really appropriate in your use case either, what I'm hearing is:   release branch: sit deployment, uat deployment, prod deployment other branches: scm checkout, build, unit testing, packaging It sounds like they are an entirely different jobs that sharing one Jenkinsfile might not be appopriate?
          Hide
          ceilfors Wisen Tanasa added a comment -

          I normally use job-dsl-plugin to manage all my jobs i.e. I won't have the pain of managing multiple jobs. Do check it out.

          Alternatively, jira-trigger-plugin could support triggers DSL, but unfortunately I don't think I have the capacity to implement that at the moment. Feel free to contribute, the repository is community driven.

          Show
          ceilfors Wisen Tanasa added a comment - I normally use job-dsl-plugin to manage all my jobs i.e. I won't have the pain of managing multiple jobs. Do check it out. Alternatively, jira-trigger-plugin could support triggers DSL, but unfortunately I don't think I have the capacity to implement that at the moment. Feel free to contribute, the repository is community driven.
          Hide
          hhkkss hhkkss added a comment -

          Thanks for the feedback. 

          Show
          hhkkss hhkkss added a comment - Thanks for the feedback. 

            People

            Assignee:
            hhkkss hhkkss
            Reporter:
            hhkkss hhkkss
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: