# Share binary between standard build and Sonar

**URL:** <https://community.sonarsource.com/t/share-binary-between-standard-build-and-sonar/145515>\
**Category:** SonarQube Server / Community Build\
**Created:** [July 31, 2025, 4:14pm UTC](https://community.sonarsource.com/t/share-binary-between-standard-build-and-sonar/145515 "2025-07-31T16:14:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Klock](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/vincent_klock/32/4685_2.png) [@Vincent\_Klock](https://community.sonarsource.com/u/Vincent_Klock)\
**Post date:** [July 31, 2025, 4:14pm UTC](https://community.sonarsource.com/t/share-binary-between-standard-build-and-sonar/145515/1 "2025-07-31T16:14:55Z")

</div>

- SonarQube Server / DCE 2025.1
- Jenkins 2.440 / Maven 3.5+

Hello,

I apologize if my question seems strange, but I failed to find an answer so far. I have been asked a question, for which I think I don’t know exactly what to answer, except: “it is how we’ve always been doing it”. One user asked me why they have to implement 2 calls to Maven in their pipeline, one to build their binary, and one for Sonar.

Basically, in our current pipelines, most of the time we have the following stages:

1. build
2. call JaCoCo and run sonar analyses
3. wait for quality gate
4. if quality gate is ok, push to binary repository

So the question is: would it be possible to merge #1 and #2 and just have one Maven run, or is it not recommended for some reasons — and if there are reasons not to do it, what are they?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 1, 2025, 2:19pm UTC](https://community.sonarsource.com/t/share-binary-between-standard-build-and-sonar/145515/2 "2025-08-01T14:19:49Z")

</div>

Hi,

Yes, absolutely. Per [the docs](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/ci-based-analysis/sonarscanner-for-maven/#invoking-the-goal), it’s actually better to run it all in one go because:

> the SonarScanner has access to the full build context and can therefore make a more thorough analysis.

Run the commands separately, and the scanner could miss important context because (per an internal thread where I was learning about this):

> Maven consecutive executions are mostly stateless.
> 
> [For instance,] If you use a [plugin](https://www.mojohaus.org/build-helper-maven-plugin/add-source-mojo.html) in your build to declare additional source folders dynamically, `mvn sonar:sonar` won’t “see” it, because the previous plugin won’t have been executed

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![Vincent\_Klock](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/vincent_klock/32/4685_2.png) [@Vincent\_Klock](https://community.sonarsource.com/u/Vincent_Klock)\
**Post date:** [August 1, 2025, 3:00pm UTC](https://community.sonarsource.com/t/share-binary-between-standard-build-and-sonar/145515/3 "2025-08-01T15:00:07Z")

</div>

> [@ganncamp](#):
>
> , and the scanner could miss important context because (per an internal thread wher

Thank you Ann, noted 🙂

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [August 8, 2025, 3:00pm UTC](https://community.sonarsource.com/t/share-binary-between-standard-build-and-sonar/145515/4 "2025-08-08T15:00:32Z")

</div>

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