Selenium with Jenkins on MAC - macos

Can someone explain step by step procedure to execute Selenium with Jenkins on MAC? There are many Video for windows but nothing on MAC.
Steps required:
How to set Classpath in terminal?
how to resolve "Permission denied" for jar files?
Run scripts in Jenkin.

You could try out the following:
How to set CLASSPATH in terminal?
A: Open new terminal you will be in your home directory example /User/pavan
You can edit .bash_profile
export JAVA_HOME=/user/pavan/jdk1.8.0_101
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib
you could add your required jar paths with colon separated.
2 How to resolve "Permission deined" for jar files?
You might tried jar command use the following:
java -jar yourtarget.jar
Run scripts in Jenkin.
You need to create a job in Jenkin dashboard.In the build section you give shell scripts or commands as shown below image:

Related

mvn not found when executed via Jenkins shell script

I have set M2_HOME under Manage Jenkins -> configure system -> Environment variables and also under Manage Jenkins -> global tool configuration.
When I use maven project, it is working fine.
But when I use freestyle project and execute shell, it throws an error "mvn not found".
But when I give echo $M2_HOME in Execute shell, it shows the correct path.
Also, when I tried $M2_HOME/mvn compile, it worked fine.
I could not figure out the exact issue.
Error
[Compile]
$ /bin/sh -xe /tmp/jenkins1984982949384007169.sh
+ mvn --version
/tmp/jenkins1984982949384007169.sh: 2: /tmp/jenkins1984982949384007169.sh: mvn: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The shell which executes the mvn command doesn't know that the path for the script in in the M2_HOME variable. The shell will only look at commands listed in the $PATH variable.
So there are two solutions:
Always use "$M2_HOME/mvn" to execute Maven (or rather "$M2_HOME/bin/mvn" since M2_HOME should point to the folder which contains bin and lib and not to the script itself).
Change the path at the top of the script to make the shell search in the right place:
export PATH="$M2_HOME/bin:$PATH"
That probably only makes sense when you run Maven more than once in the script.

Jenkins execute shell not able to find gradle commands

I am trying to trigger gradle command in execute shell of a particular node from jenkins master and it's trowing an exception as-
gradle: command not found
Build step 'Execute shell' marked build as failure
However, gradle command works if am trying to execute shell in the same node itself under local workspace.
What I understood-
Triggering any job from remote by default try to search executable like 'adb', 'gradle' in /usr/local/bin of node machine (Macintosh)
read-write access should be there for '.gradle' folder
What I have done-
added .gradle inside /usr/local/bin of slave
granted read-write access to .gradle
Here, both node-jenkins and master-jenkins have gradle v2.5 installed. Why execute shell triggered from master jenkins not able to find gradle in slave jenkins, any help would be appreciated.
try run env before your try to run gradle. and compare it to env from the command line. I think that Jenkins use another path.
I was also facing same issue where gradle command working fine on machine where jenkins is installed but the same command was not working on slave.
Solution:
You need to set GRADLE_HOME on slave.
Most important: set PATH into the slave configuration [copy the exact PATH path from slave machine and copy it into Jenkins slave configuration under Jenkins--> Manage Jenkins--> Manage Node--> NodeName(your node name)--> Configure and search for Node Properties-->Environment variables]
save
In my case I have added additional PATH env variable, then it worked.
I was also facing same issue
verify you add Gradle Plugin to your jenkins
Verify that you inside the Folder where exist the "gradle.build" file
my example: the location of my gradle.build was insifr the foulder automation-api

nohup: failed to run command `sh`: No such file or directory

I have the following pipeline script in Jenkins:
node {
withMaven(globalMavenSettingsFilePath: '/my/path/apache-maven-3.2.2/conf/settings.xml', jdk: 'JDK 1.8.0u92', maven: 'apache-maven-3.2.2', mavenSettingsFilePath: '/my/path/apache-maven-3.2.2/conf/settings.xml') {
sh '/my/path/apache-maven-3.2.2/bin/mvn clean install'
}
}
For this, I am getting:
nohup: failed to run command `sh`: No such file or directory
ERROR: script returned exit code -2
Why is this?
I am sure that the path to my Maven installation is correct. When I run a job without the pipeline, Maven builds with no errors and I can see that it uses the same path.
This might be the result of modifying PATH.
Check your script and Global Properties and remove modifications to PATH. It is now recommended to use PATH+extra instead. It would still be picked up, but without breaking actual PATH.
Related issue on Jenkins: https://issues.jenkins-ci.org/browse/JENKINS-41339
In the end, I used shell instead of sh and it worked. No idea why, they don't have a proper API.
I would suggest to use it like this:
withMaven(
maven: 'M3',
mavenSettingsConfig: 'maven-settings-for-the-task',
mavenLocalRepo: '.repository') {
// Run the maven build
sh "mvn clean install"
}
Apart from that I would not use absolute paths to global settings.xml nor to user settings.xml. I would prefer using usage of "Config File Provider Plugin" which has the advantage to have the settings.xml on Master and available on all nodes.
See also the documentation: https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Maven+Plugin
This error comes when you are trying to run script copied from windows machine to unix machine.
YOU need to change the format to unix using : dos2unix <scriptname.sh> and the run your script in unix ./<scriptname.sh>

MAVEN - Setting Path in Redhat so the maven commands can be run from anywhere

I have just installed Maven on Redhat, the apache-maven-3.3.9 is located in /root/, I ran the following command to set the path (JDK java home path already set and when I type $PATH the below path does show, along with when I type mvn --version):
export PATH=/root/apache-maven-3.3.9/bin:$PATH
The project I want to build with Maven is also in /root/ however, I cannot use the maven commands within the project or anywhere else except for /apache-maven-3.3.9/bin directory.
Any help would be much appreciated!
You need to add it to your ~/.profile file.
export PATH=$PATH:/root/apache-maven-3.3.9/bin
so that when you exit the terminal and start a new terminal instance path is not lost

Automation issue with MOS and UiAutomator

I am using the following command in APK to invoke UiAutomator based test scripts:
proc = java.lang.Runtime.getRuntime().exec("uiautomator runtest Library.jar -c com.uia.example.my.Library");
It is working fine till LOS.
But in MOS, I am getting the following error:
Unable to unlink
/data/local/tmp/dalvik-cache/arm64/sdcard#data#Library.jar#classes.dex:
Permission denied
Please provide solution for this issue.
Note: I need to run scripts in release binary. So rooting is not possible.
Use Android Testing Support Library and create a test case extending InstrumentationTestCase as explained in Testing UI for Multiple Apps.
Then run your tests using
$ ./gradlew connectedCheck
The problem is due to no write permission in /data/local/tmp/ where you placed your Library.jar file. Write permission is required to extract dex from the Jar.
May be OEMs could disable rooting and remove write permission to /data/local/tmp and that may the reason for your issue in production/release builds ..
If you use uiautomator commands like : uiautomator runtest Library.jar ....
uiautomator will search for Library.jar by default in /data/local/tmp .
You can check uiautomator shell script present in /system/bin.
export run_base=/data/local/tmp ==> Classpath for searching the dex files.
One solution could be to place Library.jar and modified uiautomator script in your application folder (data/data//files).
you have to modify run_base with your application data folder path.
You can bundle the uiautomator script and jar following the instrcutions in below link :
http://gimite.net/en/index.php?Run%20native%20executable%20in%20Android%20App
Hope it helps ... Please update about your results.

Resources