如何将Sonarqube Azure Devops管道指向另一个存储库中的不同分支?

发布于 2025-01-27 21:44:09 字数 1201 浏览 4 评论 0原文

我在Azure DevOps中有一个单独的管道进行声纳分析,该管道在Azure Devops中扫描了另一个存储库,但是,它只是在扫描主分支,我希望它可以扫描特定的分支,理想情况下,所有特征分支或我们的测试分支。

我已经尝试了几件事,但无法实现此功能,这是我的声纳管道代码的一部分(已删除/更改了任何名称/敏感信息):

resources:
  repositories:
  - repository: platform-code
    type: git
    name: platform-code
  #pipelines:
  #   - pipeline: platform-build
  #     source: platform-build
  #     trigger:
  #      branches:
   #        - feature/awesomeaddition


#trigger:
#  branches:
#    include:
#    - master
#    - features/*

stages:

- stage: Sonarqube
  variables:
    - template: variables.yaml
  jobs:
    - job: SonarqubeScan
      steps:
        - checkout: self
        - checkout: platform-code
  
        - task: SonarQubePrepare@4
          displayName: 'SonarQube Prepare'
          inputs:
            SonarQube: ${{ variables.SonarQubeServiceConnectionName }}
            scannerMode: 'CLI'
            configMode: 'manual'
            cliProjectKey: ${{ variables.cliProjectKey }}
            cliProjectName: ${{ variables.cliProjectName }}
            cliSources: '$(Build.SourcesDirectory)/platform-build'
            extraProperties: |
              sonar.branch.name='feature/awesomeaddition'

I have a separate pipeline in Azure Devops for sonar analysis, which scans another repo in Azure Devops, however, it is only scanning the master branch, I would like it to scan specific branches, ideally, all feature branches or just our test branch.

I've tried a few things but unable to get this working, here is part of my sonar pipeline code (removed/changed any names/sensitive info):

resources:
  repositories:
  - repository: platform-code
    type: git
    name: platform-code
  #pipelines:
  #   - pipeline: platform-build
  #     source: platform-build
  #     trigger:
  #      branches:
   #        - feature/awesomeaddition


#trigger:
#  branches:
#    include:
#    - master
#    - features/*

stages:

- stage: Sonarqube
  variables:
    - template: variables.yaml
  jobs:
    - job: SonarqubeScan
      steps:
        - checkout: self
        - checkout: platform-code
  
        - task: SonarQubePrepare@4
          displayName: 'SonarQube Prepare'
          inputs:
            SonarQube: ${{ variables.SonarQubeServiceConnectionName }}
            scannerMode: 'CLI'
            configMode: 'manual'
            cliProjectKey: ${{ variables.cliProjectKey }}
            cliProjectName: ${{ variables.cliProjectName }}
            cliSources: '$(Build.SourcesDirectory)/platform-build'
            extraProperties: |
              sonar.branch.name='feature/awesomeaddition'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文