简体   繁体   中英

Can I use Azure Pipelines Yaml to FTP deploy to different servers depending on the branch?

I have a test branch, and any time I push to it I want azure to build and deploy the web app to our testing FTP server we've set up in house.

Now if I merge the changes from test into master , I want any pushes to the master branch to build in the same way but deploy to our production FTP server. Is this possible using Azure Pipelines Yaml? If not, is there any official supported, non-hacky way to do this?

You can divide the whole process into two stages (build stage and FTP stage).

In YAML, you can set it to be triggered by any branch. Then the 'build stage' will be triggered by any branches.

In 'FTP stage', you could set a condition to filter trigger branches. Then the 'FTP stage' will be triggered by specific branch.

Here is an example:

trigger:
 branches:
   include:
     - '*'

stages:
- stage: A
  jobs:
    - job: 
      steps:
        -  script: echo Building!

- stage: B
  dependsOn: A
  condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/master'))
  jobs:
    - job: 
      steps:
        -  script: echo Building!

Here are the docs about Conditions and Triggers .

Hope this helps.

You can control which branches get the triggers with a simple syntax.

resources:
  pipelines:
  - pipeline: SmartHotel
    source: SmartHotel-CI 
    trigger: 
      branches:
      - releases/*
      - master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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