Azure Pipelines - 在长时间运行构建后将标签提交到 GitHub

问题描述 投票:0回答:1

我有一个用于构建 VM DevOps 映像的 Azure Pipeline,由于映像的大小,该管道需要大约 1 小时 30 才能运行。

我希望在管道末尾标记位于 GitHub 中的存储库,但是,我无法这样做,似乎凭证会在 1 小时后过期。

请看下面的代码:

- checkout: self
  persistCredentials: true
  fetchDepth: 0

###### Steps Removed To Save Length.

- pwsh: |
   ## Run CMDS which take over 1 hr.

- pwsh: |
    git config --global user.email "[email protected]"
    git config --global user.name "Azure DevOps Build Service"
    
    git checkout $(Build.SourceBranchName)

    git add --all
    git commit -m "Example Tag"
    git push origin $(Build.SourceBranchName)

    git tag $(Tag)
    git push --tags

尝试标记存储库时,出现以下错误:

“fatal: could not read Username for ‘https://github.com’: terminal prompts disabled”

如果我删除 - pwsh: 需要一个多小时的任务,管道运行正常并且存储库获得标签。

有关 persistCredential: true 的内容未按预期工作,似乎凭证仅持续一小时。

azure azure-devops azure-pipelines
1个回答
0
投票

如果您使用

persistCredentials: true
执行
checkout
任务,则整个管道中的令牌生命周期为
1hour

如果你

don't
想要使用github令牌来推送代码,正如你提到的,你可以将git推送分离到另一个工作中。在我这边检查过,您不能将新作业放在同一个管道中,您可以将存储库内容发布为工件,并在新管道中使用
pipeline resource
触发器,下载工件并推送到github存储库。

© www.soinside.com 2019 - 2024. All rights reserved.