How to setup the specific configuration for the branch repository?

vijay.nelson's Avatar

vijay.nelson

09 Apr, 2019 12:13 PM

I have a simple scenario where I want to deploy to two different locations depending on the commit happening on Dev2_TestApp branch or master

I have the below on my trunk yml configuration.

version: 1.0.{build}
configuration:
- Debug
- QA
- Release
environment:
  deploy_website: true
  site_path: C:\inetpub\API
  apppool_name: API
  site_name: API
  host_name: dev-test.co.uk;dev-test.co.uk
  protocol: http;https
  site_port: 80;443
  certificate: ;*.test.co.uk
  APPVEYOR_WAP_ARTIFACT_NAME: App
before_build:
- cmd: appveyor-retry nuget restore
build:
  publish_wap: true
  publish_nuget: false
deploy:
- provider: Environment
  name: 35.***.***.**
  on:
    configuration: Debug
skip_commits:
  message: /\[Deployed\]/

I want to change the specific configuration for my branch as below,

environment:
  deploy_website: true
  site_path: C:\inetpub\API2
  apppool_name: API2
  site_name: API2
  host_name: dev2-test.co.uk;dev2-test.co.uk
  protocol: http;https
  site_port: 80;443
  certificate: ;*.test.co.uk
  APPVEYOR_WAP_ARTIFACT_NAME: App

I have tried override the environment config on my branch yml file, but it doesnt work for me.

for:

# override settings for `master` branch
-
  branches:
    only:
      - Dev2_TestApp
  environment:
    deploy_website: true
    site_path: C:\inetpub\API2
    apppool_name: API2
    site_name: API2
    host_name: dev2-test.co.uk;dev2-test.co.uk
    protocol: http;https
    site_port: 80;443
    certificate: ;*.test.co.uk
    APPVEYOR_WAP_ARTIFACT_NAME: App

  1. Support Staff 1 Posted by Owen McDonnell on 09 Apr, 2019 04:53 PM

    Owen McDonnell's Avatar

    I just tested this scenario here with a simple example and it seems to be working fine.
    Or perhaps i misunderstood what you are trying to accomplish?

  2. 2 Posted by vijay.nelson on 10 Apr, 2019 05:56 AM

    vijay.nelson's Avatar

    Hi,
    It doesn't work for me, I'm not quite clear on this.
     branches:
        only:
          - Dev2_TestApp

    or
    branches:
        only:
          - master

    "Dev2_TestApp" - Is this the repository name of the branch ?
    For trunk branch, should I have to mention as "master" ?

    Regards,
    Nelson

  3. Support Staff 3 Posted by Owen McDonnell on 10 Apr, 2019 03:13 PM

    Owen McDonnell's Avatar

    Sorry, I believe I misunderstood your problem.

    I think you have confused the purpose of environment: section in configuration file for deployment environment. The former is just for setting environment variables on the build machine.

    From the looks of your existing config it looks like you are trying to do an agent deployment.

    In that case probably what you want to do is create 2 different environments and then access them with conditional deployment(on.branch construct) in your config file.

    Let me know if this makes sense.

  4. 4 Posted by vijay.nelson on 11 Apr, 2019 07:01 AM

    vijay.nelson's Avatar

    I tried the below, but it doesn't work though,
    version: 1.0.{build}
    configuration:
    - Debug
    - QA
    - Release
    before_build:
    - cmd: appveyor-retry nuget restore
    build:
      publish_wap: true
      project: Core.Solution.sln
      publish_nuget: false
    deploy:
    - provider: Environment
      name: 35.xxx.xx.xx
      on:
        branch: Core
        configuration: Debug
        deploy_website: true
        site_path: C:\inetpub\API
        apppool_name: API
        site_name: API
        host_name: dev-test.uk;dev-test.co.uk
        protocol: http;https
        site_port: 80;443
        certificate: ;*.test.co.uk
        APPVEYOR_WAP_ARTIFACT_NAME: App
    - provider: Environment
      name: 35.xxx.xx.xx
      on:
        branch: Core-Dev2
        configuration: Debug
        deploy_website: true
        site_path: C:\inetpub\API2
        apppool_name: API2
        site_name: API2
        host_name: dev2-test.co.uk;dev2-test.co.uk
        protocol: http;https
        site_port: 80;443
        certificate: ;*.test.co.uk
        APPVEYOR_WAP_ARTIFACT_NAME: App
    skip_commits:
      message: /\[Deployed\]/

  5. Support Staff 5 Posted by Owen McDonnell on 11 Apr, 2019 03:34 PM

    Owen McDonnell's Avatar

    All the settings you have under deploy.on key like these ...

    
        deploy_website: true 
        site_path: C:\inetpub\API 
        apppool_name: API 
        site_name: API 
        host_name: dev-test.uk;dev-test.co.uk 
        protocol: http;https 
        site_port: 80;443 
        certificate: ;*.test.co.uk 
        APPVEYOR_WAP_ARTIFACT_NAME: App
    

    ...should be put in the deployment environment you create when you go to https://ci.appveyor.com/environments/new and create a new AppVeyor agent deployment environment. You make different settings for each environment as described here.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac