1

I would like to run a yaml pipeline from one project. I have a task in my yaml to scan all the source code. Using this Yaml I would like to scan all the source code in master branch for all the project and all the repository inside the same Org.

How can I get all the repo for all the project and iterate? Can someone help me ?

test.yaml

repositories:
  - repository: justAnotherName
    type: github
    name: myGitRepo
    endpoint: myGitServiceConnection   
    trigger:    
      branches:  
        include:  
        - master
 
steps:
- task: CredScan@2
  inputs:
    toolMajorVersion: 'V2'
    outputFormat: 'tsv'
    scanFolder: '$(Build.SourcesDirectory)'
learner
  • 223
  • 3
  • 19

1 Answers1

1

If you're looking to pull every repo within a project, you have one of two options (see below). However, I'd advise caution before attempting this on a Microsoft-hosted agent, they have a 60-minute timeout by default. If you're using a self-hosted agent, you need not worry. I'd still advise breaking this up to avoid creating a long-running release that also consumes a large amount of disk space with each run.

That being said, here are the options you have:

Option 1 (Not the best) Manually add a repository: dependency for every project and a checkout: task for every repo within the projects.

This is heavily manual and would require maintenance every time a report is added.

Option 2 You can write a custom PowerShell/bash script that uses the Azure DevOps API and git to automatically scan all projects and repos within the org and pull them onto the machine.

Start by issuing a request to get all of the projects within the org:

Then, iterate through every project and get all repos:

Finally, iterate through each repo and run git clone [repository URL] to clone it onto the build agent.

NOTE: You will want to ensure to have a lot of free disk space on the agent machine and that you clean up the build space after this operation.

Max Morrow
  • 1,206
  • 4
  • 13
  • Thank you Max for the reply. I am going with option 2 .As I don’t want one pipeline to run for longer time, I am creating a pipeline to get all the repo and invoke the 2nd pipeline from 1st based on repo and project name. But I am facing one issue here . Can I read repository details from a variable? When I am trying below code, repo name is not taking from variable. Is thr any solution to this? Example: repositories: - repository: $(variable.reponame) type: git name: (variable.repioname) endpoint: myGitServiceConnection – learner Mar 02 '21 at 21:38