繁体   English   中英

Gitlab yaml 到 azure 管道 yaml 文件

[英]Gitlab yaml to azure pipelines yaml file

我正在尝试转换,但在阅读了一些来源之后,我不确定如何将与 gitlab CI 一起使用的这部分 yaml 代码转换为 azure 管道 yaml:

build:
  stage: build
  script:
    - npm run build
  artifacts:
    paths:
      - dist
  only:
    - master

deploy:
  stage: deploy
  script:
    - npm i -g netlify-cli
    - netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
  dependencies:
    - build
  only:
    - master

特别是我想在构建阶段设置工件路径,然后在部署阶段以某种方式设置它。

这是它现在在我的 azure-pipelines yaml 中的样子:

- script: |
    npm run build
  displayName: 'Build'

- script: |
    npm i -g netlify-cli
    netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod
  displayName: 'Deploy'

请参阅以下示例:

variables:
  - name: netlify.site.id
    value: {value}
  - name: netlify.auth.token
    value: {token}

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

stages:
  - stage: Build
    jobs:
      - job: ARM
        steps:
        - script: npm -version
        - publish: $(System.DefaultWorkingDirectory)
          artifact: dist
  - stage: Deploy
    dependsOn: Build
    condition: succeeded()
    jobs:
      - job: APP
        steps:
        - bash: |
           npm i -g netlify-cli
           netlify deploy --site $(netlify.site.id) --auth $(netlify.auth.token) --prod

提示 1:如果netlify.auth.tokennetlify.site.id的值对您来说非常私密,并且您不希望它在 YAML 中公开。 您可以将它们存储在变量 group 中 然后将变量部分更改为:

variables:
  - group: {group name}

请参阅此文档

Tip2:对于stage依赖,可以使用VSTS yaml中的dependsOn关键字来实现依赖。 看到这个

Tip3:在VSTS中,你必须指定stagesjobssteps作为服务器的入口点来编译相应的部分。

阶段是相关作业的集合。

作业是要由代理或在服务器上运行的步骤的集合。

步骤是构成作业的线性操作序列。

提示 4:要使用 YAML 在 VSTS 中实现发布工件,有 2 种不同的格式。 一种是我上面为你展示的。 发布关键字是发布管道工件任务的快捷方式。

另一种格式,请参阅此发布工件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM