如何在AzureDevops中将经典的构建作业转换为Yaml构建

时间:2019-11-07 13:10:01

标签: azure-devops

我们在天蓝的Devops中使用自托管代理池进行经典的工作。但是,当我们尝试将此构建作业转换为yaml方法时,在执行过程中不会分配任何代理并将其挂起。如果我正在做某事,请在这里纠正我。

错误

“所有符合条件的代理均已禁用或离线”

以下是从经典构建-代理作业转换的yaml文件

pool:
  name: MYpool
  demands: maven

#Your build pipeline references an undefined variable named ‘Parameters.mavenPOMFile’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- task: Maven@3
  displayName: 'Maven pom.xml'
  inputs:
    mavenPomFile: '$(Parameters.mavenPOMFile)'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: '$(system.defaultworkingdirectory)'
    Contents: '**/*.war'
    TargetFolder: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: Root'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: Root
  condition: succeededOrFailed()

- task: CopyFiles@2
  displayName: 'Copy wars to build directory'
  inputs:
    SourceFolder: '$(build.artifactstagingdirectory)/target'
    TargetFolder: '/home/myadmin/builds/$(build.buildnumber)'

- task: CopyFiles@2
  displayName: 'copying docker file to Build Directory'
  inputs:
    SourceFolder: Admin
    TargetFolder: '/home/myadmin/builds/$(build.buildnumber)'

- bash: |
   # Write your commands here
   mv /home/myadmin/builds/$(build.buildnumber)/mypack0.0.1.war /home/myadmin/builds/$(build.buildnumber)/ROOT.war

  displayName: 'Name war file Root.war'

- task: Docker@2
  displayName: 'Build the docker image'
  inputs:
    repository: 'mycontainerregistry.azurecr.io/myservice'
    command: build
    Dockerfile: '/home/myadmin/builds/$(build.buildnumber)/Dockerfile'
    tags: '$(Build.BuildNumber)-DEV'

- bash: |
   # Write your commands here

   docker login mycontainerregistry.azurecr.io
   docker push mycontainerregistry.azurecr.io/myservice:$(Build.BuildNumber)-DEV

  displayName: 'Push Docker Image'


- task: CopyFiles@2
  displayName: 'Copy Deployment file'
  inputs:
    SourceFolder: /home/myadmin/kubernetes
    TargetFolder: '/home/myadmin/builds/$(build.buildnumber)'

- task: qetza.replacetokens.replacetokens-task.replacetokens@3
  displayName: 'Replace image in deployment file'
  inputs:
    rootDirectory: '/home/myadmin/builds/$(build.buildnumber)'
    targetFiles: '**/*.yml'

1 个答案:

答案 0 :(得分:1)

在之前的回答中,我说当我等待近20-30分钟时,代理界面将在以下消息中提示。

enter image description here

实际上,这是一个将代理自动升级到最新版本的过程。

是的,当您将YAML与私有代理一起使用时,代理版本必须为最新版本。无论您是否添加需求。

对于我们的系统,代理版本隐含的要求,要求代理在YAML中应用最新版本时必须对此感到满意。

如果不满意,它将被阻止并且一段时间后系统将强制由代理自动执行代理升级过程。

因此,要在YAML中成功执行私人代理,请手动将该代理升级到最新代理

enter image description here


由于在此ticket中,我和我同事所说的对Microsoft都是私有的,对不起,您无法在此摘要中看到。因此,在这里获取有关它的屏幕截图,您可以参考它:https://imgur.com/a/4OnzHp3

我们仍在研究为什么系统提示如此混乱的消息,例如:All eligible agents are disabled or offline。并且,我正在尝试做出一些贡献以使此消息更加清晰,例如:no agents meet demands: agent version xxx