Jenkins – 进入另一个作业的工作空间执行脚本

huangapple go评论80阅读模式
英文:

Jenkins - Dir into another job's workspace to execute script

问题

I have a pipeline that builds two Jenkins in parallel:

  try {
    parallel (
      a: {
        script { build_a = build(job: "...", parameters: [...]) }
      },
      b: {
        script { build_b = build(job: "...", parameters: [...]) }
      },
    )
  }

The two jobs will do a full checkout of several repos, and then build. If both succeed I want to tag the HEAD of all those repos.
For that I would need to go to both build_a and build_b 's workspace and execute the git tag commands from there.
Is this possible?

Alternatively, I would need to do an added two full checkouts in the parent job in order to tag them after the two jobs succeed.

I tried looking in the documentation but it doesn't seem possible.

英文:

I have a pipeline that builds two Jenkins in parallel:

  try {
    parallel (
      a: {
        script { build_a = build(job: "...", parameters: [...]) }
      },
      b: {
        script { build_b = build(job: "...", parameters: [...]) }
      },
    )
  }

The two jobs will do a full checkout of several repos, and then build. If both succeed I want to tag the HEAD of all those repos.
For that I would need to go to both build_a and build_b 's workspace and execute the git tag commands from there.
Is this possible?

Alternatively, I would need to do an added two full checkouts in the parent job in order to tag them after the two jobs succeed.

I tried looking in the documentation but it doesn't seem possible.

答案1

得分: 1

一般来说,你不能假设工作空间在任务完成后会保留下来。这就是为什么 Jenkins 没有任何用于访问它们的命令。你可以通过 API 调用来创建一个标签吗?GitHub 有一个API可以实现这个,我相信其他提供商也有。

英文:

Generally speaking, you can't assume that the workspaces persist after the jobs have completed. That's why Jenkins doesn't have any commands for accessing them. Can you do an API call to create a tag? GitHub has an API for that, I'm sure other providers do too.

huangapple
  • 本文由 发表于 2023年7月31日 22:04:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804398.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定