Azure devops Gitlab yaml到azure管道yaml文件

Azure devops Gitlab yaml到azure管道yaml文件,azure-devops,continuous-integration,azure-pipelines,gitlab-ci,continuous-deployment,Azure Devops,Continuous Integration,Azure Pipelines,Gitlab Ci,Continuous Deployment,我正在尝试转换,但在阅读了一些源代码后,我不确定如何将这部分与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 - netli

我正在尝试转换,但在阅读了一些源代码后,我不确定如何将这部分与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
- 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'
特别是我想在构建阶段设置工件路径,然后在部署阶段以某种方式设置

下面是my azure pipelines 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
- 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

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

variables:
  - group: {group name}
看这个

Tip2:对于阶段依赖关系,可以在VSTS yaml中使用
dependsOn
关键字来实现依赖关系。看

Tip3:在VSTS中,必须指定
阶段
作业
步骤
,这些步骤用作服务器编译相应部分的入口点

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


另一种格式,请参见此

是否有办法在阶段之间保留文件夹?例如,在gitlab中,我可以这样保存它:
cache:path:-node\u modules/
@AlexT如果阶段B依赖于阶段A,那么它们可以使用工件在阶段之间传递文件夹。这是最常用的方法,也是我的方法,工作很好。你还需要其他场景吗?是的,我在这个问题中提出了问题:@AlexT,已经给了你2种方法来尝试。如果您在VSTS中有任何难题,请随时告诉我。