2

I'm working on using fastlane screengrab/snapshot to take screenshots of my android and ios app. When I run them locally on terminal, they work perfectly, but when I run them from jenkins, they fail. I'm using macOS.
Android:

/Users/shared/Library/Android/sdk/tools/emulator -avd Pixel_API_22 &
fastlane screengrab

(These 2 are in a .sh)

The first line failed: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

iOS:

fastlane snapshot

it failed while trying to build a test because of an provisioning profile error:

xcodebuild -showBuildSettings -scheme UITests -project ./abc.xcodeproj

(this is a command that fastlane snapshot execute automatically)

Again, they both run smoothly on terminal (I ran them in the same workspace as junkins)

Son Nguyen
  • 1,124
  • 2
  • 10
  • 24

2 Answers2

1

Double-check the environment settings after executing your job in Jenkins: you might see differences with the same environment settings as seen with your user account in command-line (where it is working)

The username might be different (if your Jenkins server/agent runs with another account).

The OP Son Nguyen confirms the PATH issue:

the developer who set up jenkins put a wrong path to android sdk, so I was able to run the android part by fixing the path.

And the OP adds:

fastlane was installed in /usr/local/bin while jenkins was in /User/myUser: So, somehow they didn't work well together.
I reinstalled fastlane in /User/myUser and it worked.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I use the same user for both jenkins and terminal. I tried to export ANDROID_SDK_ROOT with the sdk path, still doesn't work – Son Nguyen Mar 08 '18 at 06:33
  • Then the is another difference, in the PATH probably – VonC Mar 08 '18 at 06:36
  • I checked jenkins config and the developer who set up jenkins put a wrong path to android sdk, so I was able to run the android part by fixing the path. Any suggestion for ios why it fails to build the test from jenkins? – Son Nguyen Mar 09 '18 at 17:17
  • @SonNguyen No suggestion except there must be again a difference, either in term of environment/path or in term of file content. – VonC Mar 09 '18 at 20:27
  • I finally figured it out. fastlane was installed in /usr/local/bin while jenkins was in /User/myUser so somehow they didn't work well together. I reinstalled fastlane in /User/myUser and it worked – Son Nguyen Mar 10 '18 at 08:51
  • @SonNguyen Great! I have included your comments in the answer for more visibility. – VonC Mar 10 '18 at 08:53
0

This got it working for me.

I had to include this at the top of my script :

     #!/bin/zsh
     source ~/.zshrc

and my .zshrc had this:

    export PATH="$PATH:"/usr/local/bin/
    export SSL_CERT_FILE=/etc/ssl/cert.pem # for openssl error
    export ANDROID_HOME=/Users/jenkins/Library/Android/sdk