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

标签 azure github azure-devops gitlab yaml

所以我正在尝试学习 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/

相关文章:

azure - 尝试将 asp.net web api 部署到 azure 应用程序服务

azure - 是否可以监视 Azure 集成运行时?

git - 监控 Jenkins 中的存储库,但不要 pull

azure - 更改 Azure Pipelines 中的当前工作目录

azure-devops - 添加模板未显示在最新的 Azure DevOps 中

Azure ARM 模板

azure - 如何在外部 azure 事件目录中强制执行多重身份验证

python - 尝试下载 nltk 数据时出现 405 错误

unity-game-engine - Unity 2019 - 如何修复 TextMeshPro 2.0 错误 cs0433

azure - 使用 Azure DevOps 调用RestAPI