Different images per branch / per project

Chris's Avatar

Chris

17 Apr, 2019 02:44 PM

Hi there!

Thanks for your help in the past!

So I'm trying to achieve the following:

- on develop branch, use one azure image
- on non develop branch, dependent on operating system / project use a different azure images e.g. Unix images for unix tests / windows for windows tests

Would you have examples of that?

Chris

  1. Support Staff 1 Posted by Owen McDonnell on 17 Apr, 2019 07:55 PM

    Owen McDonnell's Avatar

    For differentiation between branches you can specialize build matrix configuration using for.matrix construct.
    While for differentiation between operating system, you can use $isLinux variable and other strategies as outlined here.

    Let me know if you have more questions or if I've misunderstood what kind of information you're looking for.

  2. 2 Posted by Chris Belfield on 17 Apr, 2019 08:10 PM

    Chris Belfield's Avatar

    We are using the hybrid model where we are using our own azure vhds, do
    you have an example like that? Different cloud images in a matrix?

  3. Support Staff 3 Posted by Ilya Finkelshte... on 17 Apr, 2019 09:17 PM

    Ilya Finkelshteyn's Avatar

    Use branches-specific configuration and use specific images for the different branches using image or environment sections, by placing them under the for.branches construct.

    #default image matrix
    image:
    - Visual Studio 2017
    - Ubuntu
    
    ############################
    # default build scenario here #
    ############################
    
    # run develop branch builds on Azure
    for:
    -
      branches:
        only:
          - develop
    
      image: AzureImage
    
      # optionally develop-specific build scenario here
    

    For the build scenario, use this part of documentation to have a different scenarios for Linux and Windows. Note that both documentation and Owen (in previous answer) mention build matrix specialization. I would not recommend it for your case, as it does not work together with branches specialization you need to use. So use other options to distinguish between Windows and Linux build like sh and cmd prefixes or $isLinux/$isWindows variables.

  4. 4 Posted by Chris Belfield on 22 Apr, 2019 04:54 PM

    Chris Belfield's Avatar

    [image: Screen Shot 2019-04-22 at 5.52.12 pm.png]
    Should I not be seeing "test script hot" as it's a PR branch?
    [image: Screen Shot 2019-04-22 at 5.52.18 pm.png]

  5. Support Staff 5 Posted by Ilya Finkelshte... on 22 Apr, 2019 05:21 PM

    Ilya Finkelshteyn's Avatar

    For PR builds branch is the base/target one, e.g. develop in your case so it follows develop scenario. And this makes sense because PR build is a build of a "virtual merge" of from head branch to the base one. Kind of "what if I merge" build.

    When you did initial commit, branch build probably happened, and that one should follow for.branches.except: develop scenario.

  6. 6 Posted by Chris Belfield on 22 Apr, 2019 06:51 PM

    Chris Belfield's Avatar

    Hmm, I didn't notice that in the history of the project? (where it build
    the branch by itself without the PR).

    Is there a log I can check?

  7. Support Staff 7 Posted by Ilya Finkelshte... on 22 Apr, 2019 07:55 PM

    Ilya Finkelshteyn's Avatar

    If it does not, check if Do not build on "Push" events is checked in general tab of the project setting by any chance. If not, check project's Events tab -- we write a warning if we skip a build. And finally if nothing helps, check webhook settings for your project on GitHub and ensure if it sends requests on push events.

    Let us know what you found.

  8. 8 Posted by Chris Belfield on 23 Apr, 2019 12:45 PM

    Chris Belfield's Avatar

    So we need the ability to only test develop independently on a "cold" image
    so that we can do a full test (which takes up to 5 hours) so we can't do
    that cold test on every commit (for obvious reasons). Could you give me an
    example where I can run a "cold image" on develop only (maybe on a
    schedule) and then use a "warm" image for the PRs.

  9. Support Staff 9 Posted by Ilya Finkelshte... on 23 Apr, 2019 08:50 PM

    Ilya Finkelshteyn's Avatar

    There are a lot of options to do that, but for me the most straightforward one would be creating of two AppVeyor projects this way:

    • Both projects connected to the same repository.

    • At least one of the projects would have URL slug with random ending. You can change it to something nicer with API call, check sample script.

    • Each project uses custom YAML.

    • Scheduled build project has default branch set to develop in UI General Settings.

    • Scheduled build project has cron schedule set in UI General Settings. Use crontab guru to test your expression.

    • Scheduled build project has Do not build on "Push" events and Do not build on "Pull request" events set in UI General Settings.

    • Scheduled build project has "cold" image test in YAML.

    • PR build project has Do not build on "Push" events set in UI General Settings.

    • Scheduled build project has "warm" image test in YAML.

    The only disadvantage of this is two build histories, but depending on the situation this even may be good. Also you can have two separate status badges on your dashboard or GitHub.

    If you do not like this approach and want to keep common project and YAML, you can condition your test script with APPVEYOR_PULL_REQUEST_NUMBER and/or APPVEYOR_SCHEDULED_BUILD environment variables. Ping with any questions if you decide to go this route.

  10. 10 Posted by Chris Belfield on 24 Apr, 2019 08:25 AM

    Chris Belfield's Avatar

    Could you provide a working example of something like this?

  11. Support Staff 11 Posted by Ilya Finkelshte... on 24 Apr, 2019 09:45 PM

    Ilya Finkelshteyn's Avatar

    I proposed two solutions above.

    First solution is creating two separate projects. This approach wrote with as much details as I could.

    Second solution is to keep a single project and YAML. If you want to stay with it, send your YAML as a text (not picture) and I will send you an example based on it.

  12. 12 Posted by Chris Belfield on 25 Apr, 2019 07:31 AM

    Chris Belfield's Avatar

    Here is our current single project appveyor config file :)

    So basically we need something that does cold (image: hc-cold) builds only
    on develop, warm builds on prs (image: hc-azure) and if you could possibly
    give us something skeleton for azure / linux (call the image hc-linux) that
    we could use?

    I will give the 2 project method a go today :)

    Thanks!

    Chris

  13. 13 Posted by Chris Belfield on 25 Apr, 2019 07:59 AM

    Chris Belfield's Avatar

    [image: Screen Shot 2019-04-25 at 8.58.50 am.png]
    Can this be enabled?

  14. Support Staff 14 Posted by Ilya Finkelshte... on 25 Apr, 2019 05:03 PM

    Ilya Finkelshteyn's Avatar

    Sure, enabled. Yes, I think that 2 projects approach is cleaner for your case.

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