# Sonarqube plugin failing due to failed export

**URL:** <https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429>\
**Category:** Java\
**Tags:** bug\
**Created:** [March 3, 2020, 10:02am UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429 "2020-03-03T10:02:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![itmecho](https://avatars.discourse-cdn.com/v4/letter/i/96bed5/32.png) [@itmecho](https://travis-ci.community/u/itmecho)\
**Post date:** [March 3, 2020, 10:02am UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429/1 "2020-03-03T10:02:15Z")

</div>

We have a build using the sonarqube addon which was working until today. It seems like travis is doing something strange when trying to decrypt a secure environment variable:

[https://travis-ci.org/manywho/sdk-java/jobs/657327826](https://travis-ci.org/manywho/sdk-java/jobs/657327826)

Line 454: exports the variable  
Line 954: Error about exporting “decrypt]”  
Line 1827: Fails due to invalid sonarqube auth

We haven’t changed anything related to the build process or the SONAR\_TOKEN variable since the last successful build. The previous build is using the same version of the sonarqube scanner

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [March 4, 2020, 12:19am UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429/2 "2020-03-04T00:19:28Z")

</div>

[Adding debug printing to show `/home/travis/.travis/job_stages`](https://travis-ci.org/native-api/sdk-java/builds/657970446) shows that the failing command [is the following](https://travis-ci.org/native-api/sdk-java/builds/657970446#L1261):

```
export SONAR_TOKEN=[unable to decrypt]

```

This is because under `secure:`, you need to place the encrypted value returned by `travis encrypt`.

* * *

The immediate failure and the unhelpful error message is because Travis’ logic doesn’t quote variable values as required by shell syntax if they have spaces.

> <https://github.com/travis-ci/travis-build/pull/1865>

* * *

Note that your build would likely fail anyway because [pull requests don’t have access to secret variables](https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml).

The documentation does mention that [Sonarcloud support only works for “internal” pull requests](https://docs.travis-ci.com/user/sonarcloud/#analysis-of-internal-pull-requests) – whatever that means.

So in addition to fixing the syntax, you’ll still need to not call `mvn sonar:sonar` for pull requests:

```auto
- if [[$TRAVIS_PULL_REQUEST == "false"]]; then mvn sonar:sonar <...>; fi

```

---

<div class="post-metadata">

**Author:** ![beng](https://avatars.discourse-cdn.com/v4/letter/b/b3f665/32.png) [@beng](https://travis-ci.community/u/beng)\
**Post date:** [March 5, 2020, 3:30pm UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429/3 "2020-03-05T15:30:51Z")

</div>

Hi,

Several other users reported a similar error, which started to appear on the 1st of March:

- [ERROR: Not authorized. Please check the properties sonar.login and sonar.password - SonarCloud - Sonar Community](https://community.sonarsource.com/t/error-not-authorized-please-check-the-properties-sonar-login-and-sonar-password/21076)
- [Not authorized using travis since 1st of march - SonarCloud - Sonar Community](https://community.sonarsource.com/t/not-authorized-using-travis-since-1st-of-march/21114)

> [@native-api](#):
>
> This is because under `secure:` , you need to place the encrypted value returned by `travis encrypt` .

I tried this, but it didn’t help.  
However, if I put the encrypted value in the `.travis.yaml` file instead of in a variable, it works.

> [@native-api](#):
>
> The immediate failure and the unhelpful error message is because Travis’ logic doesn’t quote variable values as required by shell syntax if they have spaces.

The encrypted value doesn’t contain spaces… so this shouldn’t be the reason of failure…

Do you have other ideas why reading the encrypted variable could fail?

Thanks,  
Benoit

---

<div class="post-metadata">

**Author:** ![robstoll](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/robstoll/32/3971_2.png) [@robstoll](https://travis-ci.community/u/robstoll)\
**Post date:** [March 6, 2020, 7:13am UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429/4 "2020-03-06T07:13:55Z")

</div>

I have the same problem  
[https://travis-ci.org/robstoll/niok/jobs/658417869](https://travis-ci.org/robstoll/niok/jobs/658417869)

However, in my case the exported variable seems to be successful:  
$ export SONAR\_TOKEN=[secure]  
[https://travis-ci.org/robstoll/niok/jobs/658417869#L444](https://travis-ci.org/robstoll/niok/jobs/658417869#L444)

But I still get:  
ERROR: Not authorized. Please check the properties sonar.login and sonar.password.  
[https://travis-ci.org/robstoll/niok/jobs/658417869#L586](https://travis-ci.org/robstoll/niok/jobs/658417869#L586)

---

<div class="post-metadata">

**Author:** ![robstoll](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/robstoll/32/3971_2.png) [@robstoll](https://travis-ci.community/u/robstoll)\
**Post date:** [March 6, 2020, 3:14pm UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429/5 "2020-03-06T15:14:26Z")

</div>

a solution was posted here [ERROR: Not authorized. Please check the properties sonar.login and sonar.password - #8 by stockiNail - SonarCloud - Sonar Community](https://community.sonarsource.com/t/error-not-authorized-please-check-the-properties-sonar-login-and-sonar-password/21076/8?u=robstoll)

> \<…\>  
> The definition in Travis for Sonar addon is changed:  
> \<…\>  
> To:
> 
> ```auto
> addons:
> sonarcloud:
> organization: "pepstock-org"
> token: ${SONAR_TOKEN}
> 
> ```

---

<div class="post-metadata">

**Author:** ![LorenzoBettini](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/lorenzobettini/32/4237_2.png) [@LorenzoBettini](https://travis-ci.community/u/LorenzoBettini)\
**Post date:** [April 3, 2020, 5:30pm UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429/6 "2020-04-03T17:30:06Z")

</div>

I started to experience the same problem in builds which used to work perfectly fine, and I also see this in the log

```
/home/travis/.travis/job_stages: line 796: export: `decrypt]’: not a valid identifier

```

From what I understand from this issue [https://github.com/travis-ci/travis-ci/issues/10138](https://github.com/travis-ci/travis-ci/issues/10138) if you encrypt SONAR\_TOKEN in the Travis settings, you don’t need to specify anything else in the build.

So

```auto
    addons:
      sonarcloud:
        organization: "my orga"

```

is enough to access SonarCloud

---

<div class="post-metadata">

**Author:** ![192933488S](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/192933488s/32/6202_2.png) [@192933488S](https://travis-ci.community/u/192933488S)\
**Post date:** [February 18, 2021, 10:48pm UTC](https://travis-ci.community/t/sonarqube-plugin-failing-due-to-failed-export/7429/7 "2021-02-18T22:48:01Z")

</div>

Confirmed, error disappeared. Thanks
