代码之家  ›  专栏  ›  技术社区  ›  VAAA

Azure Pipeline-自托管代理YAML如何将发布文件复制到我的Azure VM

  •  0
  • VAAA  · 技术社区  · 3 年前

    我有一个Azure管道,使用一个自托管代理池,我有以下YAML,它工作得很好:

    # .NET Desktop
    # Build and run tests for .NET Desktop or Windows classic desktop solutions.
    # Add steps that publish symbols, save build artifacts, and more:
    # https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
    
    trigger:
    - master
    # Al usuar el pool default, usara de la organizacion el pool que cree como Self hosted CustomAgentSelfInsurance
    pool: 
      name: Default
      #vmImage: 'windows-latest'
    
    #container: mcr.microsoft.com/windows/servercore:ltsc2019
    
    variables:
    - group: 'CertPass'
      #solution: '**/SelfInsurance.sln'
      #buildPlatform: 'Any CPU'
      #buildConfiguration: 'Release'
      #pathToMageTool: "\"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\mage.exe\""
    
    steps:
    
    - task: DownloadSecureFile@1
      displayName: Download Pfx
      name: myCertificatePfx
      inputs:
        secureFile: ventasmlcert.pfx
        
    - task: DownloadSecureFile@1
      displayName: Download sni
      name: snInstallPfx
      inputs:
        secureFile: SnInstallPfx.exe    
        
    - task: DownloadSecureFile@1
      displayName: Download Testpipelineapp
      name: testPipelineapp
      inputs:
        secureFile: TestPipelineapp.zip    
        
    - task: ExtractFiles@1
      inputs:
        archiveFilePatterns: '$(Agent.TempDirectory)/TestPipelineapp.zip'
        cleanDestinationFolder: false
        overwriteExistingFiles: true    
    
    #- task: PowerShell@2
    #  env:
    #    SN_INSTALL_PFX: $(snInstallPfx.secureFilePath)
    #    MYCERTIFICATE_PFX: $(myCertificatePfx.secureFilePath)
    #    MYCERTIFICATE_PFX_PASSWORD: $(certpass)
    #  inputs:
    #    targetType: 'inline'
    #    script: '&"$($ENV:SN_INSTALL_PFX)" "$($ENV:MYCERTIFICATE_PFX)" "$($ENV:MYCERTIFICATE_PFX_PASSWORD)"'
        
    - task: NuGetToolInstaller@1
    
    - task: NuGetCommand@2
      inputs:
        restoreSolution: '$(solution)'
    
    - task: VSBuild@1
      displayName: 'Build .csproj file'
      inputs:
        solution: '$(solution)'
        msbuildArgs: '/p:DeployOnBuild=true /p:SkipInvalidConfigurations=false /p:OutDir="$(System.DefaultWorkingDirectory)\publish_output"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
    
            
    # Command line
    # Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
    - task: CmdLine@2
      inputs:
        script: TestPipelineapp.exe   #'echo Write your commands here.' 
        #workingDirectory: # Optional
        #failOnStderr: false # Optional
    

    我需要的是创建一个任务,将我的构建版本文件复制到Azure VM中的一个文件夹中。

    关于我该如何做到这一点,有什么线索和例子吗?

    0 回复  |  直到 3 年前
        1
  •  0
  •   Leonardo Oliveira    3 年前

    你可以用 Environment 要为azure devops配置虚拟机以使其具有访问权限,并使用部署环境运行下载任务->复制到你的文件夹。

    文件: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/environments-virtual-machines?view=azure-devops