简体   繁体   中英

Azure DevOps - Git Repository setup

we have an application that relies on multiple independent code modules - they do no interact with each-other. See below a rough example:

  1. Module 1
    • File 1.1
    • File 1.2
    • File 1.3
  2. Module 2
    • File 2.1
    • File 2.2

........

  1. Module 1000
    • File 1000.1
    • File 1000.2

Considering the code is all for one application but each module is independent of each other, how do i set up the repository for it so that it accomplishes the following:

  • pull request for module 1 only pulls module 1
  • commit request only commits the files of module 1
  • Azure Devops deployment only deploys the files of Module 1
    • this is the most crucial part
    • I don't care if the user clones the entire 1000 module repository only to work on Module 1 as long as when the user commits the branch and prepares a deployment to Production it's only Module 1 that gets deployed - i can't have the deployment process send to production all 1000 modules just because Module 1 was modified

The only solution I see is creating a repo for each module, but I am hoping someone knows of a more elegant methodology than that.

Note: I am not a full time developer - I qualify more for Operations Management and my knowledge of Git/repos/etc is limited - so I admit i might be missing a glaring piece of information that would make this question moot.

To achieve your goals you should consider these steps:

  • proper CI/PR triggers to build only changed module - you can have multiple builds per repository. What you need is just separate YAML file
 specific path build
trigger:
  branches:
    include:
    - master
    - releases/*
  paths:
    include:
    - Module-1/*
    exclude:
    - '*'

Above configuration setup a CI trigger only for Module-1 ignoring changes in other directories. Later in that script you can preapre package and deployment only for Module-1

Above steps should give you selective builds and deployments and fails PR when changes spread across many modules. I know that this is far away from a working solution, but I hope that at least I show you direction which you should follow.

If you have many modules and donot want to create pipeline for each module, you can consider below workaround.

If the module1 is in folder module1 of your repo. You can run git command git diff --name-only HEAD HEAD~1 in a script task to get the which module get updated. And set module folder to a variable using statement ##vso[task.setvariable] . Then you can configure the Build task to build the changed module only. Please check out below example:

Check document to learn more about task.setvariable . Check here to learn more about Conditions .

steps:
- powershell: |
    #get the changed files
    $a = git diff --name-only HEAD HEAD~1  

    #get the changed module folders
    $folders = $a | foreach {$_.split("/")[0]}

    #assign the folders to variable folderName
    echo "##vso[task.setvariable variable=folderName]$folders" 


 #this build task will only be executed when module1 changed
- task: VSBuild@1
  displayName: Build Module1
  condition: contains(variables.folderName, 'module1')

#this build task will only be executed when module2 changed
- task: VSBuild@1
  displayName: Build Module2
  condition: contains(variables.fileName, 'module2')

Above yaml is a simple example. You might need to change the powershell task scripts a little bit according to your project. You can use only one build task, if all the modules use the same build configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM