gpt4 book ai didi

azure - 是否可以在位于 Github 的 YML 中查看 Gitlab 存储库?

转载 作者:行者123 更新时间:2023-12-03 05:37:28 27 4
gpt4 key购买 nike

所以我正在尝试学习 Azure DevOps 的部署。我在 Gitlab 中有这个 Angular 应用程序,它已经有一个 CI/CD 管道,其中包含 jenkins 到 kubernetes 集群。所以我想通过 YAML 对 Azure Devops 做同样的事情。根据 Azure docs 这是不可能的直接来自 gitlab。

所以我想做的是从 github 创建 CI 管道,它需要 checkout来自 gitlab UI 存储库并构建它以进行部署。

我在下面的管道 YAMl 文件中创建了一个存储库资源。 Azure 给我错误提示:

Repository JpiPipeline references endpoint https://gitlab.com/myusername/myUiRepo.git which does not exist or is not authorized for use

trigger:
- master


resources:
repositories:
- repository: UiPipeline. #alias
type: git
name: repository_name
# ref: refs/heads/master # ref name to use; defaults to 'refs/heads/master'
endpoint: https://@gitlab.com/myusername/myUiRepo.git # <-- Is this possible


stages:
- stage: Checkout
jobs:
- job: Build
pool:
vmImage: 'Ubuntu-16.04'
continueOnError: true
steps:
- checkout: JpiPipeline
- script: echo "hello to my first Build"

最佳答案

YAML 管道尚不支持存储库类型 gitlab。目前支持的类型有git、github、bitbucket,参见supported types .

获取 gitlab 存储库源的解决方法是在脚本任务中运行 git 命令。

对于下面的示例 Yaml 管道:

- checkout: none以避免 checkout github 源代码。

使用git clone https://username:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a0d0c1d3d3d7cfd2c4e0c7c9d4ccc1c28ec3cfcd" rel="noreferrer noopener nofollow">[email protected]</a>/useraccount/reponame.git在脚本任务中克隆 gitlab 存储库。

stages:
- stage: Checkout
jobs:
- job: Build
pool:
vmImage: 'Ubuntu-latest'
steps:
- checkout: none
- script: |
git clean -ffdx
git clone https://username:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="deaebfadada9b1acba9eb9b7aab2bfbcf0bdb1b3" rel="noreferrer noopener nofollow">[email protected]</a>/useraccount/reponame.git
#if your password or username contain @ replace it with %40

您的 gitlab 存储库将克隆到文件夹 $(system.defaultworkingdirectory)/reponame

另一个解决方法是使用经典 UI 管道。经典 UI 管道支持 Gitlab 存储库类型。

您可以选择Use the classic editor创建经典的 ui 管道。

enter image description here

当您选择源页面时。选择其他git并点击Add connection添加您的 gitlab 存储库 url。然后管道将获取您的 gitlab 存储库的源代码。

enter image description here

关于azure - 是否可以在位于 Github 的 YML 中查看 Gitlab 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61368533/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com