Start Appium from jenkins file

Hello All,

I would like to start the Appium from Jenkins file using shell script. When I try it says “appium command not found”.

When the tests are run locally I am starting the appium server programmatically and stopping once the execution is complete. If the same code is pushed to repo and Jenkins pipeline job uses the repo to run the test fails. It says The main Appium script does not exist at ‘/Users/jenkins/home/workspace/mob-smoke-test-android/Serenity_Framework/appium/build/lib/main.js’. Why it is trying to find the appium/main.js inside the jenkins workspace?

When I launch appium manually to run the jenkins pipeline job all tests are working fine. But I want to start Appium either from Jenkins file using shell script or programmatically as part of my framework resolving the above error.

Any help is much appreciated. Thank you.

Screen Shot 2021-01-20 at 10.45.14 PM

programmatically do in script:

ls -l
echo $PATH
java -version

check output and compare with same done manually. looks like environment where you execute script has no PATH and other stuff. you need inject them.

Hello @Aleksei,

I added the below lines in my jenkins file.

            sh "whoami"
            sh "pwd"
            sh "ls -l"
            sh "echo $PATH"
            sh "java -version"
            sh "echo $JAVA_HOME" 

When I run the pipeline job, I see the below in console
[Pipeline] sh 12:28:30 + whoami 12:28:30 jenkins
[Pipeline] sh 12:28:31 + pwd 12:28:31 /Users/jenkins/home/workspace/mob-smoke-test-android
[Pipeline] sh 12:28:31 + ls -l
12:28:31 total 16
12:28:31 -rw-r–r-- 1 jenkins staff 2677 Jan 21 12:28 Jenkinsfile
12:28:31 -rw-r–r-- 1 jenkins staff 717 Jan 7 16:54
12:28:31 drwx—rwx 12 jenkins staff 384 Jan 21 12:28 Serenity_Framework
[Pipeline] sh 12:28:32 + echo /usr/bin:/bin:/usr/sbin:/sbin:/Applications/apache-maven-3.6.3/bin:/Users/jenkins/.nvm/versions/node/v13.5.0/bin/appium
12:28:32 /usr/bin:/bin:/usr/sbin:/sbin:/Applications/apache-maven-3.6.3/bin:/Users/jenkins/.nvm/versions/node/v13.5.0/bin/appium
[Pipeline] sh 12:28:32 + java -version
12:28:32 openjdk version “13.0.2” 2020-01-14
12:28:32 OpenJDK Runtime Environment (build 13.0.2+8)
12:28:32 OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
12:28:33 + echo /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
12:28:33 /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home

But Still I get the error

12:41:15 java.lang.ExceptionInInitializerError
12:41:15 at com.TWG.Mobile.testRunners.TestRunners.startAppium( 12:41:15 Caused by: io.appium.java_client.service.local.InvalidServerInstanceException: The main Appium script does not exist at ‘/Users/jenkins/home/workspace/mob-smoke-test-android/Serenity_Framework/appium/build/lib/main.js’
12:41:15 at com.TWG.Mobile.testRunners.TestRunners.startAppium(

I have manually verified the given comments in terminal as well as script. Both are same. It is becoming clueless for me since ages.

Please help me to solve this issue.

how appium was installed on machine and you starting it?
i see “/Users/jenkins/.nvm/versions/node/v13.5.0/bin/appium” while error is “/Users/jenkins/home/workspace/mob-smoke-test-android/Serenity_Framework/appium/build/lib/main.js” we see here “Serenity”. you should ask at “Serenity” foorum.

I am installing appium with NPM command with “-g” (means for every user on computer) and starting appium in console programmatically with just “appium” command.