Conditionally enable services

mloskot's Avatar

mloskot

20 May, 2016 11:11 AM

Hi,

I have a build matrix with four build jobs based on certain environment variables:
https://ci.appveyor.com/project/lexicalunit/nanodbc

Currently, I am using database services and this has worked well for me:

services:
  - mssql2014   # start SQL Server 2014 Express
  - mysql       # start MySQL 5.x service
  - postgresql  # start PostgreSQL 9.x service

This starts all services for each of the jobs - so there is always a bunch fo redundant services started.
I would like to add more, e.g. SQL Server versions, and I'd like to save on boot time.

So, I'm looking for a way to conditionally enable services.
I have found this, but it discusses different scenario - I don't want to maintain per branch configuration:
http://help.appveyor.com/discussions/suggestions/232-conditional-bu...

On Travis CI, I can enable services via addons per a matrix job:
https://github.com/lexicalunit/nanodbc/blob/master/.travis.yml

Is it possible to achieve the same thing in appveyor.yml?

  1. 1 Posted by mloskot on 20 May, 2016 02:14 PM

    mloskot's Avatar

    I think I found a workaround:

    before_test:
      - ps: |
          if ($env:DB -Match "MSSQL2008") {
            net start 'MSSQL$SQL2008R2SP2'
          } elseif ($env:DB -Match "MSSQL2014") {
            net start 'MSSQL$SQL2012SP1'
          }
    

    Would it be considered a recommended way or is there a better way?

  2. Support Staff 2 Posted by Feodor Fitsner on 20 May, 2016 02:16 PM

    Feodor Fitsner's Avatar

    Exactly, I was about to suggest the same, as those "services" are just Windows services.

    -Feodor

  3. 3 Posted by mloskot on 20 May, 2016 02:20 PM

    mloskot's Avatar

    Awesome, thanks!

  4. mloskot closed this discussion on 20 May, 2016 02:20 PM.

  5. mloskot re-opened this discussion on 20 May, 2016 03:53 PM

  6. 4 Posted by mloskot on 20 May, 2016 03:54 PM

    mloskot's Avatar

    Fedor,

    Could you help me to figure out what is service name for MySQL and PostgreSQL?

    These both are failing for me:

    net start mysql
    net start postgresql
    

    with net : The service name is invalid.

    Thanks,
    Mat

  7. Support Staff 5 Posted by Feodor Fitsner on 20 May, 2016 04:15 PM

    Feodor Fitsner's Avatar

    Should be:

    Start-Service MySQL57
    Start-Service postgresql-x64-9.5
    
  8. 6 Posted by mloskot on 20 May, 2016 06:14 PM

    mloskot's Avatar

    It helped. Thanks again.
    Mat

  9. mloskot closed this discussion on 20 May, 2016 06:14 PM.

Comments are currently closed for this discussion. You can start a new one.

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