Webhook Response: Server Unreachable

Hi!

I have an instance of sonarqube inside and EC2 and a server on express (localhost for Now)

I’m trying to create the following workflow:

  • Push repo to github
  • Trigger sonar-qube with github actions:
on:
  # Trigger analysis when pushing in master or pull requests, and when creating
  # a pull request. 
  push:
    branches:
      - main
  pull_request:
      types: [opened, synchronize, reopened]

name: Main Workflow
jobs:
  sonarqube:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        # Disabling shallow clone is recommended for improving relevancy of reporting
        fetch-depth: 0
    - name: SonarQube Scan
      uses: sonarsource/sonarqube-scan-action@master
      env:
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
  • Trigger webhook and send info to my server (now on localhost).

The GitHub actions is being properly executed but I can’t manage to connect the webhook.

These are the variables I have inside my project.properties:

sonar.projectKey=
sonar.login= 
sonar.password=

Inside my sonarqube instance using the UI I have set up the serverUrl to my EC2 instance url

And lastly, I have enabled localhot webhook URLs and my hook url look like this:

http://localhost:3000/sonar-hook.

I’m not sure what I’m missing.

This is the response I’m getting:

Response: Server Unreachable
Duration: 1ms

Any ideas?

Thank you in advance!!

I’ve managed to solve the problem using ngrok.

Even if you can override the webhook config to add a localhost address it is not working.

Using the same configuration and generating a tunnel with ngrok and setting up that URL everything is working properly.

Steps

commands for mac users:

  • Install ngrok
brew install ngrok/ngrok/ngrok
ngrok authtoken <generate the token inside your ngrok account>

# lacunh your server
npm run dev 

# connect the server to ngrok
ngrok http SERVER_PORT

Use the ngrok https forwarding link as your sonarqube webhook endpoint

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.