Pull request decoration did not happen. Failed to access Bitbucket Cloud, the repository or the pull request

Hi SonarSource community,

We are using Sonarqube Developer Edition Version 8.9 (build 43852). We have a problem with the Bitbucket Cloud ALM integration. Based on the version 8.9 tutorial I configured the ALM integration and the Pull request decoration. When we run the bitbucket pipeline we got this error message.

Pull request decoration did not happen. Failed to access Bitbucket Cloud, the repository or the pull request

  • Repository SLUG set to the project as in the documentation.
  • Bitbucket “pull request” read permission is available.
  • SONAR_TOKEN and SONAR_URL provided in BB
  • Oauth is working
  • Pull request decoration is set in the project settings.
2021.06.14 14:58:53 WARN  ce[------------------------][c.s.F.D.A.B.A] Pull request decoration did not happen. Failed to access Bitbucket Cloud, the repository or the pull request
java.lang.IllegalStateException: Error returned by Bitbucket Cloud: Resource not found
	at org.sonar.alm.client.bitbucket.bitbucketcloud.BitbucketCloudRestClient.handleError(BitbucketCloudRestClient.java:169)
	at org.sonar.alm.client.bitbucket.bitbucketcloud.BitbucketCloudRestClient.doCall(BitbucketCloudRestClient.java:155)
	at org.sonar.alm.client.bitbucket.bitbucketcloud.BitbucketCloudRestClient.doGet(BitbucketCloudRestClient.java:149)
	at com.sonarsource.F.D.A.B.A.G.getPullRequest(Unknown Source)
	at com.sonarsource.F.D.A.B.A.A(Unknown Source)
	at com.sonarsource.F.D.A.B.A.A(Unknown Source)
	at com.sonarsource.F.D.A.B.F.A(Unknown Source)
	at com.sonarsource.F.D.c.A(Unknown Source)
	at java.base/java.util.Optional.ifPresent(Unknown Source)
	at com.sonarsource.F.D.c.B(Unknown Source)
	at com.sonarsource.F.D.c.A(Unknown Source)
	at org.sonar.ce.async.SynchronousAsyncExecution.addToQueue(SynchronousAsyncExecution.java:27)
	at com.sonarsource.F.D.c.A(Unknown Source)
	at java.base/java.util.Optional.ifPresent(Unknown Source)
	at com.sonarsource.F.D.c.finished(Unknown Source)
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:118)
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:109)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:91)
	at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:63)
	at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:81)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:212)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:194)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:160)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
![config|690x490](upload://k6oxQj54vBYKdxrc9BAmc82G1GI.png)

  • We can see the quality gate status and results in the web UI. Everything looks good except the pull request decoration.

  • I’m increased the log level to DEBUG in the “System Info” screen. But it’s telling the same issue without useful info about the root cause.

How could we debug the connection between BB and SQ to find the cause of this issue?

1 Like

Hi @Balazs_Szecsi,

Can you also confirm, because it is not 100% clear from your post, that you set and double checked your Workspace ID in the Global ALM Integration settings in the SonarQube?

Workspace ID – The workspace ID is part of your bitbucket cloud URL https://bitbucket.org/{WORKSPACE-ID}/{repository-slug}

This usually might happen if the there is a typo in the Workspace ID or Repository SLUG. In rare cases it might also happen if there is some issue with access token or pull request ID.

Hi Lukasz,
I’m double checked the workspace ID and SLUG values in the bitbucket URL.
Example: Log in with Atlassian account
Both match in the configuration. How could I check the access token or Pull request ID part?

BR,
Balazs

The pull request ID/Key is visible in the URL of Bitbucket PR. Example:

https://bitbucket.org/workspace/project/pull-requests/1 - here 1 is the ID/Key of the pull request.

Scanner needs to know about this ID. How do you run the scanner? Do you use bitbucket-pipelines.yml, if so with which scanner?

Hi Lukasz,

Yes we are using bitbucket pipelines with Gradle.

image: androidsdk/android-30


clone:

  depth: full


pipelines:

  pull-requests:

    '**':

      - step:

          name: Lint -> Unit test -> Build debug

          caches:

            - gradle

            - gradlewrapper

          script:

            - git fetch --all --tags

            - git rev-list --count HEAD

            - ./gradlew clean

            - ./gradlew lintDebug

            - ./gradlew testDebugUnitTest

            - ./gradlew runSonar

            - ./gradlew assembleDebug

          artifacts:

            - app/build/outputs/**

            - app/build/reports/**

  tags:

    'external/*':

      - step:

          name: Lint -> Unit test -> Appcenter

          caches:

            - gradle

            - gradlewrapper

          script:

            - git fetch --all --tags

            - git rev-list --count HEAD

            - ./gradlew clean

            - ./gradlew lintDebug

            - ./gradlew testDebugUnitTest

            - ./gradlew clean appCenterAssembleAndUploadDebug appCenterAssembleAndUploadDebugExt appCenterAssembleAndUploadProd appCenterAssembleAndUploadProdExt

          artifacts:

            - app/build/reports/**

            - app/build/outputs/**

    'release/*':

      - parallel:

          - step:

              name: Lint -> Unit test

              caches:

                - gradle

                - gradlewrapper

              script:

                # Fetch git tags used by build script

                - git fetch --all --tags

                # Clean

                - ./gradlew clean

                # Lint check

                - ./gradlew lintDebug

                # Unit test check

                - ./gradlew testDebugUnitTest

          - step:

              name: Build release -> Process apk

              caches:

                - gradle

                - gradlewrapper

              script:

                # Fetch git tags used by build script

                - git fetch --all --tags

                # Clean

                - ./gradlew clean

                # Create unsigned apk and move it to another directory

                - ./gradlew assembleRelease -Punsigned

                - rm -rf app/build/outputs/apk/release-unsigned

                - mv app/build/outputs/apk/release app/build/outputs/apk/release-unsigned

                # Create Accedo-signed release

                - ./gradlew assembleRelease

                # Get versionName and versionCode. Not using $BITBUCKET_TAG environment variable because on manual run it may not be available

                - tag=`git describe --tags --abbrev=0`

                - echo $tag

                - versionName=${tag//"release/"/""}

                - echo $versionName

                - versionCode=`aapt dump badging app/build/outputs/apk/release/accedo-magentatv-android-phone-release-$versionName.apk | grep -o "versionCode=[^,]*" | cut -d"=" -f 2 | cut -d " " -f 1 | tr -d "'"`

                - echo $versionCode

                # Rename apks

                - mv app/build/outputs/apk/release/accedo-magentatv-android-phone-release-$versionName.apk app/build/outputs/apk/release/accedo-magentatv-android-phone-accedo-signature-$versionName-$versionCode.apk

                - mv app/build/outputs/apk/release-unsigned/accedo-magentatv-android-phone-release-unsigned-$versionName.apk app/build/outputs/apk/release-unsigned/accedo-magentatv-android-phone-unsigned-$versionName-$versionCode.apk

              artifacts:

                - app/build/reports/**

                - app/build/outputs/**

definitions:

  caches:

    gradlewrapper: ~/.gradle/wrapper