【问题标题】:Azure DevOps container jobs; run commandline commands on a 'second' imnageAzure DevOps 容器作业;在“第二个”图像上运行命令行命令
【发布时间】:2020-01-16 09:20:12
【问题描述】:

我正在使用 Azure DevOps 容器作业和服务容器。我的用例如下,我(不幸的是)必须在 Private Hosted Build 代理上做所有事情。

我正在容器 A 中作为容器作业运行我的作业。 我在 Container B 上安装了使用命令行的特定软件(Fortify)

基本上,我希望在容器 A 上运行的步骤之一在容器 B 中运行(使用工作区中的代码进行强化扫描)。当然我可以在一份单独的工作中完成,但我更愿意在同一份工作中完成。

目前有什么想法吗?

谢谢

【问题讨论】:

  • 如果这个 steo 在 A 和 B 中做不同的事情,那么分开它可能是一个更好的选择。或者,如果这是您想要的,您可以设置步骤目标docs.microsoft.com/en-us/azure/devops/pipelines/process/…?也可以试试docs.microsoft.com/en-us/azure/devops/pipelines/process/…,你可以为同一个步骤设置不同的容器。
  • 感谢您的回答,这一步目标似乎正是我所需要的。在下面的答案中,我读到这是 sprint 163 版本的新功能。但是很酷,正是我需要的!
  • 我很乐意提供帮助,但这实际上不是答案,而是评论。我已经发布了我的答案,如果你愿意,你可以接受它作为答案。谢谢。

标签: azure-devops


【解决方案1】:

太棒了,我刚刚读到这个功能将在 sprint 163 版本中提供! https://docs.microsoft.com/en-us/azure/devops/release-notes/2020/sprint-163-update

resources:
  containers:
  - container: python
    image: python:3.8
  - container: node
    image: node:13.2

jobs:
- job: example
  container: python

  steps:
  - script: echo Running in the job container

  - script: echo Running on the host
    target: host

  - script: echo Running in another container, in restricted commands mode
    target:
      container: node
      commands: restricted

【讨论】:

    【解决方案2】:

    您可以使用Step target 选择步骤将在哪个容器或主机上运行。

    例如:

    resources:
      containers:
      - container: pycontainer
        image: python:3.8
    
    steps:
    - task: SampleTask@1
      target: host
    - task: AnotherTask@1
      target: pycontainer
    

    【讨论】:

    • 我将自己的答案作为已接受的答案。我无法让 step target 工作,所以我感觉它将在 163 版本中发布。然后我又可能错了。无论如何很高兴知道这一点,谢谢!
    猜你喜欢
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-08
    • 1970-01-01
    • 2020-04-02
    • 2018-07-17
    • 1970-01-01
    相关资源
    最近更新 更多