Integrate Jenkins with JIRA

Maro Hamamjyan August 16, 2019

Hello,

 

I have installed Jenkins on my Windows, Installed the JIRA Plugin, configured the web hook in JIRA, but seems it is not working. No error occurs, just it seems that Jira is not connected to Jenkins and I think I have wrong configuration in Jenkins.

What should be the URL for JIRA sites (Specify the root URL of your JIRA installation, like http://issues.apache.org/jira/) ?  Credentials?

 

Thanks in advacne

 

 

1 answer

1 accepted

0 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 21, 2019

Hello @Maro Hamamjyan , 

In order to answer your questions:

  • The URL for the Jira site is the one you use to connect to Jira in your browser. For example, in your case since you are using Jira Cloud (replace NAME with your Jira Cloud instance name): https://NAME.atlassian.net
  • The credentials that you have to use in Cloud are: the email address you use to log-into Jira (in other words, your Atlassian Account) as the username and the API Token as the password.

However, in case this won't help, can you please provide more details on what you are doing (the exact steps you are following) and what is failing? 

 

Cheers,
Dario

Maro Hamamjyan September 25, 2019

Hello Dario,

Many thanks for you reply and readiness to help!

I am not using could, JIRA is on server in my case. I entered the URL of Jira In add sites and added Credetioal (in my case it is not working with email address but the windows username and password), after validation I got the error:

 

A problem occurred while processing the request. Please check our bug tracker to see if a similar problem has already been reported. If it is already reported, please vote and put a comment on it to let us gauge the impact of the problem. If you think this is a new issue, please file a new issue. When you file an issue, make sure to add the entire stack trace, along with the version of Jenkins and relevant plugins. The users list might be also useful in understanding what has happened.

Stack trace

java.lang.NullPointerException
 at hudson.plugins.jira.JiraSite$DescriptorImpl.doValidate(JiraSite.java:1190)
 at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)
 at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
 at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
 at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:77)
 at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
 at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
 at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
 at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:535)
 at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
 at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
Caused: javax.servlet.ServletException
 at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:797)
 at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
 at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:280)
 at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
 at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
 at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
 at org.kohsuke.stapler.Stapler.invoke(Stapler.java:676)
 at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
 at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
 at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
 at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
 at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
 at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:99)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
 at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
 at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
 at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
 at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
 at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
 at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
 at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
 at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
 at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
 at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
 at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
 at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
 at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
 at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
 at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1701)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1668)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
 at org.eclipse.jetty.server.Server.handle(Server.java:502)
 at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
 at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
 at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
 at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
 at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
 at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
 at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
 at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
 at java.lang.Thread.run(Unknown Source)
Maro Hamamjyan September 25, 2019

Hello Dario the problem described above is solved, but I still get issues to make the job in Jenkins work automatically. I have followed this tutorial https://www.youtube.com/watch?v=IYx3x2oVvZc,  

in my case when adding the word "build" in comments does nothing in Jenkins. Maye that be because I had to use not the main site URL in Sites URL in Jenkins, but exactly the project URL? How is Jenkins being connected with Jira webhook? Is this URL enough to make the webhook work? http://localhost:8080/jira-trigger-webhook-receiver

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 26, 2019

Hi @Maro Hamamjyan ,

Before going any further please confirm my understanding:

  1. You are using Jira Server
  2. You have both, Jira and Jenkins installed on the same machine
  3. You have correctly configured the plugin on Jenkins side with Jira base URL and credentials
  4. You have configured the webhook on Jira side but when you comment an issue no build is triggered.

 

If my understanding is correct, then the first thing is indeed to make sure you are using the correct URL in the Webhook confirguration.

I can see you are just using the same URL shown in the video but please notice that your URL can be different. As written in the Jira trigger plugin for Jenkins instructions:

3. Set URL to: ${Jenkins URL}/jira-trigger-webhook-receiver/ e.g. http://localhost:8080/jenkins/jira-trigger-webhook-receiver/

 

Please review the instructions by clicking on the below link and, in case you won't still be able to trigger builds, please refer to the troubleshooting section:

  • https://github.com/jenkinsci/jira-trigger-plugin

    Troubleshooting

    Build is not triggered

    Firstly, enable Jenkins logging at FINE level for troubleshooting: com.ceilfors.jenkins.plugins.jiratrigger.webhook. You should see "Received Webhook callback ..." log messages when Jenkins is receiving webhook events from JIRA.

    If you are not seeing anything in the log, your problem will either be in JIRA configuration or the network connectivity in between JIRA and Jenkins:

    • Make Webhook configuration more lenient for testing:
      • Remove JQL configuration in JIRA Webhook page if you configure one
      • Try to update an issue again and check if you are getting the logs now. If not, you might have network connectivity problem, proceed below.
    • If using JIRA Cloud:
      • Your Jenkins must be hosted with 80 or 443 port
    • If you own JIRA Server:
      • SSH to JIRA machine.
      • Try to cURL Jenkins URL and make sure that you can get a response back.
      • If you are getting a timeout, your firewall rule might be blocking JIRA Webhook events to be sent to Jenkins. You'll need to fix this for this plugin to work.

    If you are seeing "Received Webhook callback ..." but your build is not triggered, your configuration for this plugin in Jenkins might be too restrictive, please double check.

Maro Hamamjyan September 27, 2019

Hello Dario,

1. Yes I am using JIra server

2. Jenkins is not on the same machine in JIRA, as in JIRA server the localhost:8080 is already being used by JIRA, will it be right t have Jenkins in the same server?

3. I think I have correctly configured the Jenkins side, In URL section I entered the JIRA base URL and in credentials I have my JIRA username and password

4. Yes I have configured the webhook on Jira side, but can you please help me by telling what should be the webhook URL. Should it be something for example like this:

MyJiraServerBaceURL/jenkins/jira-trigger-webhook-receiver/  

or like this:

MyJenkinsURL/jenkins/jira-trigger-webhook-receiver/

 

Thanks in advance

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 1, 2019

@Maro Hamamjyan ,

Please notice that if Jira and Jenkins are not on the same machine then you cannot use localhost:

Localhost is only used to refer to applications running on the same machine and It will never work if they are running on different machines. For details see:

 

Therefore, in order to summarize:

  • The webhook url for Jenkins is the URL that Jira has to use in order to connect to Jenkins. So, you have to provide the url to access Jenkins installed on your local machine (assuming that Jira can connect to your local machine).
  • Localhost can only be used when the applications are running on the same machine they are being called from (so not in your case)
  • The URL to connect to Jenkins from your Jira would be: protocol (http:// or https://), ip address of your machine (e.g. 192.168.xxx.xxx), port (e.g. :8080) path to the resource (e.g. /jenkins/jira-trigger-webhook-receiver/ or /jira-trigger-webhook-receiver/)
  • For more details on what a URL is please refer to: https://en.wikipedia.org/wiki/URL

 

 

Cheers,
Dario

Maro Hamamjyan October 1, 2019

Hello Dario,

 

Thanks for your help, I was able to configure Jenkins so that now the job works!

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 1, 2019

Nice one @Maro Hamamjyan ! :)

I am happy to know I was able to help. 

 

Have a nice day,
Dario

Suggest an answer

Log in or Sign up to answer