How to perform a sonarqube analysis from drone io in github

0 votes

I am running sonar scans on github's pull requests from drone.io. This is the procedure I am following:

  1. PR is made
  2. Drone.io build is triggered
  3. Gradle task is executed
  4. Gradle's Sonar plugin with Drone's environment is run

The command I use in drone build:

gradle/wrapper all sonarqube \
 -Dsonar.analysis.mode=preview \
 -Dsonar.github.pullRequest=$DRONE_BUILD_NUMBER \
 -Dsonar.github.oauth=<github_token>

I am unable to find the PR ID in the drone environment. Is there any other way I can find it?

Jul 6, 2018 in Git & GitHub by Damon Salvatore
• 5,980 points
2,301 views

1 answer to this question.

0 votes

DRONE_PULL_REQUEST  env variable holds the pull request number(Check This). You can access all the environment variables through your build logs. You can do this by adding env command in your yaml file:

pipeline:
  build:
    image: golang
    commands:
      - env # dump environment variables

Your build logs after execution:

...
DRONE_PULL_REQUEST=42
DRONE_BUILD_EVENT=pull_request
...

Pull request is only set if drone is building a pull request hook.

answered Jul 6, 2018 by DareDev
• 6,890 points

Related Questions In Git & GitHub

0 votes
1 answer

Trying to analyse Sonarqube from Drone.io in Github PRs

Just try the below steps.The DRONE_PULL_REQUEST environment variable has ...READ MORE

answered Jun 27, 2018 in Git & GitHub by shubham
• 7,340 points
931 views
0 votes
1 answer

How to share images in GitHub from local system?

Hi@akhtar, You can follow the below steps to ...READ MORE

answered May 7, 2020 in Git & GitHub by MD
• 95,440 points
1,184 views
0 votes
1 answer

How to create branch in GitHub from my local Git repo?

Hi@akhtar, To sync your existing branch in GitHub, ...READ MORE

answered May 7, 2020 in Git & GitHub by MD
• 95,440 points
621 views
0 votes
1 answer

How to get changes from master branch to a new branch in Git?

Hi@akhtar, You need to check out the branch and ...READ MORE

answered Jan 4, 2021 in Git & GitHub by MD
• 95,440 points
890 views
0 votes
1 answer

How to give a file execute mode permissions in Git?

You can easily do this in one ...READ MORE

answered Aug 7, 2018 in Git & GitHub by Sophie may
• 10,610 points
20,354 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,439 views
+2 votes
1 answer
0 votes
1 answer

How to do a re-merge into another branch in git

Seems like you want to rebase your ...READ MORE

answered May 7, 2018 in Git & GitHub by DareDev
• 6,890 points
2,196 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP