Run a command only in a specific `osx_image`

I have a relatively simple question.

Consider the following .travis.yml file:

language: swift
os: osx
osx_image:
- xcode10.2
- xcode11
- xcode11.4
script:
    - swift --version
    - ./set_credentials.sh
    - swift package generate-xcodeproj  # only execute for 'xcode10.2'
    - xcodebuild -quiet -scheme "SpotifyAPI-Package" -destination 'platform=macOS' test -only-testing "SpotifyAPIMainTests/AuthorizationScopesTests"

How do I change this so that the “swift package generate-xcodeproj” script is only executed for the xcode10.2 image? For all of the other images, this script is not necessary.

Just a thought, I would grab a snapshot of xcode10.2? Seems like the most logical solution.

I don’t understand the relevance of this answer. How does this address my question?

How do I "grab a snapshot of xcode10.2"?

1 Like

Use the TRAVIS_OSX_IMAGE predefined environment variable:

if [[ $TRAVIS_OSX_IMAGE == "xcode10.2" ]]; then swift package generate-xcodeproj; fi
Imprint