cd, cat commands not execute in Jenkins - jenkins

when i try to use cd, cat commands in jenkins job, it doesnot execute these commands.
I give all permission to that directory but jenkins show error.
CONSOLE OUTOUT:
Started by user Amrit Subedi Running as SYSTEM Building in workspace
/var/lib/jenkins/workspace/todolist-app [todolist-app] $ /bin/sh -xe
/tmp/jenkins4194062835107740167.sh
cd /home/amrit/Jenkins/docker /tmp/jenkins4194062835107740167.sh: 2: cd: can't cd to /home/amrit/Jenkins/docker Build step 'Execute shell'
marked build as failure Finished: FAILURE
Please tell me the solution, if you know its solution.

please try to add the following line at the beginning of your "Execute shell" Build steps :
#!/bin/sh

Related

Error "$ cmd /c call C:\Windows\TEMP\jenkins6446000872510816227.bat The syntax of the command is incorrect."

Error "$ cmd /c call C:\Windows\TEMP\jenkins6446000872510816227.bat The syntax of the command is incorrect." while executing job for running JMeter test in Jenkins
Going to TEMP folder there was no jenkins6446000872510816227.bat file error aswell. What could be teh issue and what is the solution for this?
Expecting my job build be SUCESS but it is a failure due to this error
Your question doesn't have sufficient amount of details so we cannot troubleshoot your issue.
It's possible to run JMeter script in command-line non-GUI mode like:
c:\apps\jmeter\bin\jmeter.bat -n -t test.jmx -l result.jtl
It's possible to run Windows batch scripts in Jenkins
If it doesn't work for you first check that you can run JMeter test without issues in command-line non-GUI mode on the Jenkins build agent and then double check the syntax of your "Execute Windows batch command" section of the job.
More information: The Complete Guide to Continuous Integration With Jenkins

Build step 'Execute shell' marked build as failure on Jenkins CI without any error

I have jenkins CI integrated into my project so whenever I push my changes to github it automatically starts the test cases and builds and deploys the project to the server. I am getting this weird error after all the test cases are passed. It also says "tests failed" but shows no test as failed. Can I get to the main problem explicitly as I have no clue what is going wrong.
Stack Trace in the end:
Tests Failed
1416 examples, 0 failures
Took 187 seconds (3:07)
Build step 'Execute shell' marked build as failure
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 78221 killed;
[ssh-agent] Stopped.
[Slack Notifications] found #203 as previous completed, non-aborted build
[Slack Notifications] will send OnRepeatedFailureNotification because build matches and user preferences allow it
Finished: FAILURE
My main script is as follows:
#!/bin/bash -ex
bundle exec rubocop
./script/setup_test $#
bundle exec parallel_rspec $# spec/
bundle exec yarn test:ci
Failure is detected by non-zero exit code. You have multiple commands in your script. One of the commands must have returned non-zero exit code.

Jenkins can't find directory when executing shell command

I want to execute these shell command in my Jenkins job.
cd /Users/username/Desktop/JenkinsProject
javac Jenkins.java
java Jenkins
However when I try to build I get the error:
Running as SYSTEM
Building in workspace /Users/Shared/Jenkins/Home/workspace/JenkinsExample
[JenkinsExample] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh
+ cd /Users/username/Desktop/JenkinsProject
/Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh: line 2: cd: /Users/username/Desktop/JenkinsProject: Not a directory
Build step 'Execute shell' marked build as failure
Gitcolony notification failed - java.lang.IllegalArgumentException: Invalid url:
Finished: FAILURE
It looks like it can't find the folder when running the commands with Jenkins?
If I dont use Jenkins but run the commands in my terminal everything works fine.

Jenkins Startup a Command Line Executable

I'm new to Jenkins and i'm trying to setup a CI pipeline for a macOS Server / iOS environment. My environment integrates with Xcode server and one of the things I want to do is run a command line application that talks to Xcode server API and processes the last set of integrations. My command line application works properly when invoked in the terminal but I would like Jenkins to be able to invoke this as one of the build steps.
My execute shell build step looks like this:
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
security unlock-keychain -p ${KEYCHAIN_PASSWORD} ${KEYCHAIN_PATH}
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ${KEYCHAIN_PASSWORD} ${KEYCHAIN_PATH}
xcrun xcodebuild clean build CODE_SIGN_IDENTITY="${CODE_SIGNING_IDENTITY}" PROVISIONING_PROFILE=${PROVISIONING_PROFILE} OTHER_CODE_SIGN_FLAGS="--keychain ${KEYCHAIN_PATH}"
sh /usr/local/bin/my-command-line-app
The build is successful but fails when trying to invoke the command line app.
The error I get from the jenkins console is:
cannot execute binary file
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Now I have placed this executable in 2 locations both of which failed.
1. sh /usr/local/bin/my-command-line-app
2. sh /Users/Shared/Jenkins/Home/workspace/my-command-line-app
I also tried chmod +x to the my-command-line-app to try and change the permissions but this still results in the same error.
If anyone has any tips on how to configure this, I would appreciate it.

Jenkins shell script to git pull to production directory

I have a really simple Jenkins setup where it pulls down updates from BitBucket and runs some tests which all work lovely.
Jenkins and the testing website are both the same server so I want it to head off to my live website directory and pull down the repository that its just tested.
When I try and access : /var/www/vhosts/mysite/httpdocs/whatever/ I get a script error stating that this isn't a directory.
What would be the best way to do this?
Error is as follows:
[Pheme CI] $ /bin/sh -xe /tmp/hudson5490778292870793122.sh
+ cd /var/www/vhosts/mysite.co.uk/httpdocs/
/tmp/hudson5490778292870793122.sh: line 2: cd: /var/www/vhosts/mysite.co.uk/httpdocs/: Not a directory
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Edit this appears to be a permissions issue will update when its sorted!
Right simply put this comes down to the Jenkins user not having access to the directory I needed it to, I simply
chown jenkins <dir>
and it all works fine! There is probably a better way to do this.

Resources