I added an Execute Shell build step in my jenkins job.
I need to start Oracle NoSQL shell and run some DDLs.
I wrote shell script.
#Run Client
java -jar /root/software/kv-3.2.5/lib/kvcli.jar -host localhost -port 5000
#Run scripts
plan remove-table -name PersonnelUni1To1FK -wait
plan remove-table -name HabitatUni1To1FK -wait
When I excecute the same from my teminal, it's working fine. Becuase after 1st command database shell started and remaining scripts ran over that shell.
But build failed in Jenkins.
Jenkins job console output:
+java -jar /root/software/kv-3.2.5/lib/kvcli.jar -host localhost -port 5000
kv-> + plan remove-table -name PersonnelUni1To1FK -wait
/tmp/hudson2708562803834708095.sh: line 17: plan: command not found
Build step 'Execute shell' marked build as failure
Its trying to execute this all on my ubuntu shell not on database shell.
plan is a command to be executed by the shell, right? The error message just says that it doesn't find the command, so the problem could be the setting of the PATH variable. What happens if you specify the absolute path to plan in your shell script? Alternatively, make sure that the PATH variable on Jenkins is correct.
As a workaround,
I put all my scripts
plan remove-table -name PersonnelUni1To1FK -wait
plan remove-table -name HabitatUni1To1FK -wait
and many more...
in a file /home/dev/ons/oracle-kv-db.script
modified shell command for jenkins job
java -jar /root/software/kv-3.2.5/lib/kvcli.jar -host localhost -port 5000 < /home/dev/ons/oracle-kv-db.script
Now it does not need database shell explicitly.
Related
I want to execute the curl command in Shell Script with Jenkins.
Executing Shell Script alone from remote works very well.
However, running shell scripts through Jenkins will result in an infinite load as shown below.
Let me know how to fix it.
myShellScript
#!/bin/sh
echo "curl Start"
curl --request GET 'http://127.0.0.1:8080/server/someting/work'
echo "curl End"
================================================
my jenkins Execute shell script on remote host using ssh
==================================================
Jenkins Log Result
It's been like that for an hour, like the image below.
Connection logs do not exist in the URL.
And
ssh account#my-test-server "/home/account/folder/myShellScript.sh"
It worked well when I executed the command as above.
Please help me.
Unable to execute shell scripts on Cygwin(mintty terminal) using Jenkins pipeline but I can able to execute same scripts directly on Cygwin(mintty terminal), cygwin is installed on jenkins windows agent, anything I am missing on Jenkins windows agent to configure? and also my shell scripts are not executing on cygwin when using the Jenkins, they are executing on windows command prompt, can someone please advise how to make the jenkins to use the cygwin terminalto execute shell scripts instead of command prompt? .Thank you.
Below is the Jenkins pipeline how I am calling test.sh(test.sh is on jenkins windows agent)
stage('Import') {
steps {
script {
sh "/home/kumar/test.sh"
}
}
}
I see below error when execute the build.
/home/kumar/test.sh
FIND: Invalid switch
mv: cannot stat '/home/kumar/TEST_FILES/*': No such file or directory
below find command used in script.
find /cygdrive/d/Jenkins/workspace/sam-org/testing/app_name/src/abc -name "*.dsx" -exec cp "{}" /home/kumar/ITEST_FILES \
I was trying to run some commands inside a powershell script. The scrpt execution doesn't show any error. Script content is like:
Export-PfxCertificate –Cert $selectedcert_CA –FilePath "C:\\Windows\\System32\\CA_cert.pfx" -Password $SecurePassword -Verbose -force
But when I execute the powershell script from ruby as:
powershell.exe -file file.ps1 arg1 arg2
It displays file is created on path but I don't see any file created. If I run the same command separately (not in script just as a powershell command), it creates the file perfectly.
Is there any rights issue or I need to run the script with some permissions.
This snippet will run the powershell console with administrative rights
PS> Start-Process powershell -Verb runAs
Hi i have created a batch file (run.bat) that after execution connects me to UNIX server with help of plink. But issue starts from this point i have to execute a script after connection to my server the script contains a command sudo -l. After the execution i get the error as mentioned in subject can anyone help me on this issue ??
Batch File-:
"C:\Program Files\PuTTY" plink -ssh -pw Tos#12Ts w44dvftyw#caa1607UX009.wvd.abcd.net /opt/sieb/w44dvftyw/run.sh
Script file(run.sh) -:
#!/bin/bash
sudo -l
It says
sudo: command not found
But when i run my script normally on UNIX server it runs with no issues. What am i missing here to make it work this way please help.
Scripts such as ~/.profile or ~/.bash_profile responsible for setting up the current user's PATH are run only on login shells.
Running sh -c 'somescript' (as performed by ssh host 'somescript') is neither a login shell, nor an interactive shell; thus, it does not gain the benefit of such scripts.
This means that additions to the PATH (in your case, /usr/local/bin) may not be present with commands run in this way.
Among your options:
Pass the PATH you want as part of the command to remotely run. This might look like:
plink -ssh user#host "PATH=/bin:/usr/bin:/usr/local/bin /opt/sieb/w44dvftyw/run.sh"
Embed a working value in the script you're running:
#!/bin/bash
PATH=/bin:/usr/bin:/usr/local/bin
# ...put the rest of your script here.
I'm trying to get My jmeter test plan to execute in Jenkins. Both jmeter and Jenkins are installed on my local windows machine. I've set up some properties in Jmeter and verified that I can run them from the cmd line successfully with this command: C:\Users\MikeL\Documents\apache-jmeter\bin>jmeter -n -t testApp.jmx -l log.jtl -Jenv=dev -JloopCount=2 Now in Jenkins I've created a new project, create two new parameters and entered the following in "execute shell" based off of exapmples I was able to find on the web.I haven't configured anything else in Jenkins. sh jmeter.sh -n -p user.properties -t C:/Users/MikeL/Documents/apache-jmeter/bin/testApp.jmx -l log.jtl -Jenv=dev -JloopCount=1 suffice to say this script won't build my jmeter test. I recieve this error: Cannot run program "sh" (in directory "C:\Program Files (x86)\Jenkins\workspace\LOS API Regression Tests"): CreateProcess error=2, The system cannot find the file specified
If anybody has any clues I'd be very grateful!
Add this path C:\Users\MikeL\Documents\apache-jmeter\bin to your Environment Variables PATH.
Then Jenkins Build step should be Windows Batch Command
Then the command should be jmeter -n -t testApp.jmx -l log.jtl -Jenv=dev -JloopCount=1
Update:
If you do not want to set the path, just directly give below command as Windows Batch Command.
C:\Users\MikeL\Documents\apache-jmeter\bin\jmeter.bat -n -t C:\Users\MikeL\Documents\apache-jmeter\bin\testApp.jmx -l log.jtl -Jenv=dev -JloopCount=1
Use either Ant/Maven/Gradle to run jmeter tests in the non-gui mode. They can also be integrated with Jenkins
JMeter-Ant
JMeter-Maven
The problem here is cross environment. you need to be running this with windows batch command instead of execute shell. windows wont recognize sh as executable.
C:\Users\MikeL\Documents\apache-jmeter\bin>jmeter -n -t testApp.jmx -l log.jtl -Jenv=dev -JloopCount=2
Run the above in execute windows batch mode