Swiftlint: Enabling SwiftLint for XcodeServer CI

Created on 22 Jun 2016  路  8Comments  路  Source: realm/SwiftLint

I want to receive SwiftLint warnings for each one of my XcodeServer/CI integrations. I currently only receive one warning due to "SwiftLint not installed...".

I have a project which uses the SwiftLint Xcode integration build phase script
if which swiftlint >/dev/null; then swiftlint else echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi

I also have a CI system set up through XcodeServer which runs my unit tests reliably in each integration. I have installed SwiftLint on the _xcsbuildd user (default install location is /usr/local/bin/swiftlint), added the appropriate information for SwiftLint into it's $PATH, and I am easily able to run SwiftLint from terminal and my bot's pre-integration run script. However, I don't receive SwiftLint warnings in my integration output, I only receive the single warning stating "SwiftLint not installed, download from https://github.com/realm/SwiftLint"

How can I install SwiftLint in a way which will allow my integrations to show warnings found by SwiftLint?
Thank You!

question

Most helpful comment

aha!
sticking export PATH="/usr/local/bin:$PATH" in the build phase script fixed it for me, now seeing swiftlint warnings in my integration dashboard. Thank you! :)

All 8 comments

What user is running which swiftlint? Where have you installed SwiftLint? Is it available to the user invoking xcodebuild's path? Do you have the "inherit environment" checkbox checked in your build phase run script? Why is which swiftlint failing?

The bot runs under the _xcsbuildd user, so this is the user which will be running which swiftlint. SwiftLint is both installed under my regular user account, as well as on the _xcsbuildd user account (I used the .pkg for my account and since I can only access _xcsbuildd through terminal I used brew for that account). I see that swiftlint is located in /usr/local/bin after installing and this directory is in the $PATH. SwiftLint is available from the command line on both user accounts (additionally, I can add the line swiftlint lint to my bot's "Before Integration Run Script" and I can see the expected output in the integration logs).
I can't locate the "inherit environment" checkbox that you mentioned, can you further specify?

It seems Xcode Server does not use shell settings on executing jobs.
There is a radar about that https://openradar.appspot.com/22424243.

Ah so you may need to use the explicit path

If I understand the radar correctly, the issue there is that calling something in the bot script doesn't have the proper path set up by default.
My bot script is written like so and will run without issue:

export PATH="/usr/local/bin:$PATH
export LANG=en_US.UTF-8
cd my-repo
rm -rf Pods
rm Podfile.lock
pod install
swiftlint lint

SwiftLint runs perfectly fine there but that output only appears in the integration log after the integration. My goal is to get the warnings from Swiftlint to appear in the integration dashboard under the "Warnings" section.

Did you confirmed that /usr/local/bin was included in PATH on running SwiftLint Xcode integration build phase script?

aha!
sticking export PATH="/usr/local/bin:$PATH" in the build phase script fixed it for me, now seeing swiftlint warnings in my integration dashboard. Thank you! :)

Great. Glad it was so simple to fix. Seems like XcodeServer still has some ways to go for usability though 馃槵

Was this page helpful?
0 / 5 - 0 ratings