Alternative solution for JIRA webhook on non-standard port?

Hey everyone! I’m trying to set up continuous integration for our staging server using Jenkins and JIRA. I want to use the Jira Trigger Plugin to create Jira issues on builds and trigger stuff based on Jira status. But I’m running into a problem with the webhook setup.

My Jenkins is running on port 8081 because 80 and 8080 are already taken. The thing is, JIRA Cloud only allows webhooks on port 80 for HTTP. When I try to set up the webhook with my URL (my.domain:8081/jira-trigger-webhook-receiver), JIRA rejects it right away.

I’ve tried not specifying the port in the URL like the JIRA docs suggest, but that doesn’t work either. Has anyone found a way around this? I really want to use this plugin, but I’m stuck. Any ideas or workarounds would be super helpful!

Here’s a quick example of what I’m trying to do:

def setup_webhook(url):
    if ':80' in url or ':' not in url:
        return 'Webhook accepted'
    else:
        return 'Error: Invalid port'

# This fails
result = setup_webhook('http://my.domain:8081/jira-trigger-webhook-receiver')
print(result)  # Output: Error: Invalid port

Any suggestions on how to make this work with my current setup? Thanks in advance!

I faced a similar issue when setting up Jenkins with JIRA Cloud. One effective workaround is to use a reverse proxy like Nginx or Apache. Configure the proxy to listen on port 80 and forward requests to your Jenkins instance on port 8081. This way, you can set up the webhook in JIRA using the standard HTTP port while still running Jenkins on your preferred port.

Here’s a basic Nginx configuration example:

server {
    listen 80;
    server_name your_domain.com;

    location /jira-trigger-webhook-receiver {
        proxy_pass http://localhost:8081;
    }
}

After setting this up, you can use ‘http://your_domain.com/jira-trigger-webhook-receiver’ as the webhook URL in JIRA. This solution maintains the security of your setup while complying with JIRA’s port restrictions.

I’ve been in your shoes, and I can tell you there’s another approach that might work for you. Instead of messing with reverse proxies, have you considered using a serverless function as a middleman? I set up an AWS Lambda function that receives webhooks from JIRA on port 80, then forwards them to my Jenkins instance on the non-standard port.

It’s pretty straightforward to implement. You create a Lambda function with an API Gateway trigger on port 80. The function takes the incoming webhook payload, does any necessary processing, and then sends it to your Jenkins URL on port 8081.

This solution has a few benefits. It’s scalable, low-maintenance, and you don’t need to worry about configuring and managing a reverse proxy server. Plus, you can add extra logic in the Lambda function if you need to filter or transform the webhook data before it hits Jenkins.

Just remember to secure your Lambda function properly and handle any potential errors in the forwarding process. It’s worked like a charm for me, and it might be worth exploring for your setup too.

have u tried using a cloud proxy service like cloudflare? it can handle the port forwarding for u. set it up to listen on port 80 and forward to ur jenkins on 8081. its pretty easy to configure and u dont need to mess with ur own server setup. might be worth a shot if the other solutions didnt work out