简体   繁体   中英

Deploy project using git With (Respository with different folder estructure than local)

I'm learning a bit about git and devops and I'm trying to deploy aa couple of scripts using azure devops pipelines.

The flow that i have in mind is something like:

Git trigger -> git pull command -> run a test command

In the repository I have this folder structure:

project
|
└───folder1
│       file111.txt
│       file112.txt
│       ...
│   
└───folder2
│       file111.txt
│       file112.txt
│       ...
│   
└───folder3
│       file111.txt
│       file112.txt
│       ...

However, for the deploy, The folder1 is part of 1 VM (this VM only gonna have this folder) and the other 2 folders gonna be in another VM.

Finally, the folder3 needs to be into the folder2 in the VM.

The structure in the VM,s will be:

VM1:

folder1
│   file111.txt
│   file112.txt

VM2:

folder2
│   file011.txt
│   file012.txt
│   │
│   └───folder3
│       │   file111.txt
│       │   file112.txt

Any idea how i can du this using git? from your experience, this is the best approach to do this?

I'm thinking I can use the Copy file Task but I'm not sure if I can copy only the files added/modified in the repo.

Thanks in advance

The build agent working directory is the folder you will use to accomplish your requirement. When you add your Azure pipeline.yml file on a github repository the source code will be downloaded automatically on the sourcesDirectory. The default working directory for devOps agents is C:\agent\work .

Your repository if you do not have multiple checkouts will be downloaded into $(Pipeline.Workspace)/s/

In the.YML file you can add an AzureFileCopy task to copy on the selected VM. For example you can have two or three tasks depending on your copy needs.

- task: AzureFileCopy@4
  inputs:
    SourcePath: '$(Pipeline.Workspace)/s/folder2'
    azureSubscription: 'subscription'
    Destination: 'AzureVMs'
    storage: 'rmstaccount'
    resourceGroup: 'rg'
    MachineNames: 'vmName'
    vmsAdminUserName: 'username'
    vmsAdminPassword: 'password'
    TargetPath: 'destinationFolder'
    skipCACheck: false

Azure File Copy arguments:

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-file-copy?view=azure-devops

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