在舞台上部署工作之前运行其他工作
在部署作业运行之前,是否可以在作业中运行任务/脚本?我在环境中获得了批准,我希望由部署作业触发,但是它似乎需要在运行JOB1之前获得批准,而不是在Job1中运行任务,然后在运行部署工作之前要求批准。
我希望它在“ Job1”中运行所有工作,然后要求对部署作业进行批准。这可能吗?
我有类似于以下内容:
- stage: 1
variables:
- group: global
jobs:
- job: 'job1'
steps:
- task: DownloadPipelineArtifact@2
...
- task: ExtractFiles@1
...
- script: |
...
- deployment:
environment: DEV
strategy:
runOnce:
deploy:
steps:
- script: |
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,不。 扩展模板,然后在管道执行之前评估管道中的所有依赖关系。例如,运行时确定管道是否有权使用变量组 +服务连接,或者允许执行管道的人员使用这些资源。
它在每个阶段都做同样的事情。在执行之前,它评估工作中的依赖项,并确定需要批准或检查。它将这些“检查”泡出来。开始一个舞台并完成工作的一半是为了意识到舞台首先不应该执行舞台是相当危险的。
重要的是要注意,“部署”是一种“作业”,每种
job
可能会在不同的代理商上运行,因此下载工件以节省时间(这似乎是在您的示例)无法如您所示。如果您想暂停管道中执行中期执行并等待用户 - interaction,则有`手动验证任务'可以暂停并等待用户单击“继续”。这没有强制执行谁可以单击,但它通知一组用户,该任务正在等待他们的参与。重要的是要召集此任务是 agentless :它不会在您的代理池中运行。一个很好的参考示例将在将流量重新降低到网站(流量管理器,部署插槽等)之前暂停。
Unfortunately, no. The pre-process step within the pipeline run expands the templates and then evaluates all the dependencies within the pipeline before the pipeline executes. For example, the runtime determines if the pipeline has permission to use variable groups + service connections, or that the person executing the pipeline is allowed to consume those resources.
It does the same thing for each stage. Prior to execution, it evaluates the dependencies within the jobs and determines if Approvals or Checks are required. It bubbles these "checks" to the Stage. It would be fairly dangerous to start a stage and get halfway through the work only to realize the stage should never been executed in the first place.
It is important to note that "deployment" is a type of "job", and each
job
potentially runs on different agents, so downloading the artifacts to save time (which is what appears to be happening in your example) won't work as you've illustrated.If you want to pause the execution of the pipeline mid-execution and wait for user-interaction there is the `Manual Validation Task' which can pause and wait for a user to click continue. This doesn't enforce who's allowed to click, but it notify a set of users that the task is waiting for their involvement. It's important to call out that this task is agentless: it doesn't run in your agent pool. A good reference example would be pausing before re-enabling traffic to a website (Traffic Manager, Deployment Slot, etc).
是的
如果我正确理解的话,您(像我一样)想准备一个构建,并与管道互动,以将go-nogo与其他管道的部署到环境中。
如果是这种情况,我不建议上述情况
,那么我必须说您需要两个不同的管道。
环境批准必须在不同的管道中完成,您可以从第一个构建中获取工件。
我建议在上面的方案中推荐
以下一部分使用多个阶段。开发,舞台和prd。
开发环境不需要验证,而是其他两个需求。因此,就我的开发而言,在Job
WaitforValidation
时,我正在检查上一个构建是否成功,并且阶段是否不是开发。如果是这样,则它绕过工作并直接进入Nest作业,部署。如果
WaitforValidation
作业没有绕过,则需要验证以继续使用管道。有很好
,但如果有人会看到以后的情况,则 请继续进行构建
WaitforValidation
成功,然后继续构建。
我希望我与您的问题相提并论。
Yes
If I understand correctly, you (like me) want to prepare a build and have a human interact with the pipeline to give the go-nogo to the rest of the pipeline which is the deployment to an environment.
What I do not recommend for the above scenario
If that's the case, then I have to say that you need two different pipelines.
the environmental approval has to be done in a different pipeline where you pick up the artifact from the first build.
What I do recommend for the above scenario
The following part is using multiple stages. Dev, staging and prd.
Dev environment does not need a validation but other two needs. So, in my case of dev, while on job
waitForValidation
I am checking if the previous build was successful and if the stage is not development. If it is, then it bypasses the job and goes directly to the nest job, deployment.In case the
waitForValidation
job is not bypassed, a validation is needed to continue further with the pipeline.In job deployment, there are two
if
s probably out of your scope of the question but good to have in case someone else sees that in the future:waitForValidation
was successfulthen continue with build.
I hope I am in par with your questions.