# Azure DevOps | MonoRepo | Node.js - Not finding sources

**URL:** <https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437>\
**Category:** SonarQube Cloud\
**Tags:** azuredevops, monorepo, typescript, scanner\
**Created:** [May 5, 2023, 7:49pm UTC](https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437 "2023-05-05T19:49:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdamN](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@AdamN](https://community.sonarsource.com/u/AdamN)\
**Post date:** [May 5, 2023, 7:49pm UTC](https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437/1 "2023-05-05T19:49:23Z")

</div>

Template for a good new topic, formatted with [Markdown](https://commonmark.org/help/):

- ALM used :  
Azure DevOps
- CI system used:  
Azure DevOps
- Scanner command used when applicable (private details masked)

```auto
- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'Sonar Cloud'
    organization: '13311015-canada-inc'
    scannerMode: 'CLI'
    configMode: 'manual'
    cliProjectKey: '<our key>'
    cliProjectName: '<our name - same as key>'
    cliSources: 'services/service1'

```

- Languages of the repository  
Typescript
- Only if the SonarCloud project is public, the URL
  - And if you need help with pull request decoration, then the URL to the PR too

- Error observed (wrap logs/code around with triple quotes ``` for proper formatting)  
No Errors. But when viewing the result, there is no code and no errors
- Steps to reproduce  
We have a monorepo containing client/backend code. Structure is like:

```auto
/root
  - /services
    - /service1
      - sonar-project.properties
      - tsconfig.json
      - package.json
      - /src
        - ... folders and sources
   - /service2
     - sonar-project.properties
     - tsconfig.json
     - package.json
     - /src
       - ... folders and sources
- /clients/react-native
  - sonar-project.properties
  - package.json
  - /src
     ....
- /libraries
  - /lib1
     - sonar-project.properites
     - package.json
     - /src
       ... sub folders and files

```

I have found with the `sonar-scanner`, going to the specific project source it runs fine, finds code/issues.

```auto
% sonar-scanner \
  -Dsonar.organization=my-org \
  -Dsonar.projectKey=my-service \
  -Dsonar.sources=. \
  -Dsonar.host.url=https://sonarcloud.io \

```

However, when triggering a build, no sources are found.

We use yarn monorepo. The build is something like:

```auto
1. download node
2. checkout depth 0
3. run - task: SonarCloudPrepare@1 (for 1 of 4 backend services)
4. yarn install 
5. yarn build-libraries
6. run - task: SonarCloudAnalyze@1 (passes)
7. run - task: SonarCloudPrepare@1 (for 2 of 4 backend services)
8. run - task: SonarCloudAnalyze@1 (passes)
9. - task: SonarCloudPublish@1 (correctly links to PR, and gives a link)
10. run tests
11. run webpack
12. other steps to deploy

```

- Potential workaround  
Can run sonar-scanner manually. But really trying to figure why the pipeline doesn’t find anything…

**Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!**

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 8, 2023, 9:27am UTC](https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437/2 "2023-05-08T09:27:12Z")

</div>

Hey there.

It’s not clear to me what you mean by “not finding sources”. Are you receiving ane error message? Seeing something strange in the UI? Just want to make sure I fully understand the issue!

---

<div class="post-metadata">

**Author:** ![AdamN](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@AdamN](https://community.sonarsource.com/u/AdamN)\
**Post date:** [May 8, 2023, 4:59pm UTC](https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437/3 "2023-05-08T16:59:16Z")

</div>

I can see that my SonarCloud project has been uploaded, and the correct branch:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/7/1/7183219577afd5c2a81fa3d586496aa4e848fdd3.png)

When I click on that branch I see the following:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/f/f/ff7261fa66a38936243fa70bc68ebd7d7958ec46.png)  
(Passed, but no bugs, no smells, no security… nothing)

And when I click on the ‘Code’ tab, its empty:  
 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/1/4/14b6031e7c5bed0b309dfb8a075a96677cb94d26.png)

In contrast, when I manually ran sonar-scanner, then bugs and smells appeared, and code shows folders that I can drill down.

So when doing through Azure, we get no code showing which is why I’m saying its not finding the sources…

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 9, 2023, 1:27pm UTC](https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437/4 "2023-05-09T13:27:30Z")

</div>

It looks like you’re running this on a pull request, where only the changed code will appear.

Are you changing code in this branch / pull request, other than configuration files such as adding SonarCloud analysis?

---

<div class="post-metadata">

**Author:** ![AdamN](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@AdamN](https://community.sonarsource.com/u/AdamN)\
**Post date:** [May 10, 2023, 12:44am UTC](https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437/5 "2023-05-10T00:44:25Z")

</div>

> [@Colin](#):
>
> Are you changing code in this branch / pull request, other than configuration files such as adding SonarCloud analysis?

Ah, you might be on to something! No, I’m only checking in config files and pipeline.yml changes in order to trigger the build. Its not a PR request, its currently just an Azure DevOps pipeline triggered on any commit to the branch.

This is in my pipeline now:  
steps:

```auto
- checkout: self
  fetchDepth: 0

- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'Sonar Cloud'
    organization: '<ommited>'
    scannerMode: 'CLI'
    configMode: 'manual'
    cliProjectKey: '<omitted>'
    cliProjectName: 'service1'
    cliSources: 'services/service1'

```

Is there something I’m missing? Or is there a better practice I should be doing to get this setup initially?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 10, 2023, 9:06am UTC](https://community.sonarsource.com/t/azure-devops-monorepo-node-js-not-finding-sources/90437/6 "2023-05-10T09:06:18Z")

</div>

Thanks!

Okay, you’re not analyzing a pull request but you are analyzing a [short-lived branch](https://docs.sonarcloud.io/enriching/branch-analysis-setup/#long-lived-and-short-lived-branches), which also only shows changes on New Code. Once merged into your main branch, I expect you’ll see full results.

I have been pushing internally for a while that analysis setup from a short-lived branch or pull request can be confusing for new users, who see no results (because the config files aren’t analyzed by SonarCloud). I’ll add this topic to the list.
