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.
Related
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
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
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 Pipeline job doesn't trigger pipeline job using jenkins cli. When i run jenkins as anaonymous this works, but when i create a user/admin it fails.
I have a job A which has parameters and passes the same to Pipeline Job. This is a Master-slave setup. This is how i run:
sudo java -jar /home/user/jenkins-cli.jar -s $JENKINS_URL build pipeline_job -p parameter_Name="$parameter_Name" -p parameter_Name2="$parameter2_Name"
1.) I tried using options, "-auth" , "-username -password" but doesn't work.
errors:
No such command: -auth
No such command: -ssh
2.) Another option is paste the public key in SSH section http://jenkin_url/me/configure , but still it fails
error:
java.io.IOException: Invalid PEM structure, '-----BEGIN...' missing
Is there i am missing anything ?
I Found the solution,
1.) used SSH CLI.
In my case i was using master-slave environment, connection was made using SSH keys vice-versa. In order to trigger the build using Jenkins CLI, place the SSH keys both public & private and place them in http://jenkinsURL/user/username/configure
Here username= the one used to connect the nodes.
Trigger the job as below:
java -jar /home/username/jenkins-cli.jar -s $JENKINS_URL -i /home/username/.ssh/id_rsa build JOBNAME
Note: This is one way but cloudbees doesn't encourage this approach.
2.) There is new approach i.e., using API token authentication.
Go to http://jenkinsURL/user/username/configure
Copy the API token
trigger the build as below:
java -jar /home/username/jenkins-cli.jar -s $JENKINS_URL -auth username:apitoken /home/username/.ssh/id_rsa build JOBNAME
Note: For using API token option, download the latest jar file
I am using jenkins to build a bunch of legacy code. The legacy code comes with some complex build scripts, written in csh.
The build scripts do not check for or exit on errors. The user is expected to scan the output for error messages. However, this does not work well with Jenkins.
I am executing the csh build scripts in a jenkins "shell execution" build step. For example:
export PATH=`pwd`/ALL/bin:/usr/local/bin:/usr/bin:/bin:$PATH
cd ATLb2.00/expt_02.0
csh 020.com
When I run this from the command line, I can also use the -e option:
csh -e 020.com
In this case, as I expect, the script is run, but when the first error is encountered, the script stops and returns a non-zero code. However, when I try this in Jenkins, the build fails as soon as it gets to the csh -e command, without executing any of the script.
The error I get in Jenkins is:
+ csh -e 020.com
Build step 'Execute shell' marked build as failure
On the command line, the script is run and I see all kinds of output, until something fails, and then the script exits. On Jenkins the script seems to fail without even running. There is no output, and even scripts with no failures will not run for me under jenkins with the -e option.
What's up?
I recommend that you specify csh on a more global level and then execute the commands in a Jenkins build step.
If you want to use csh for all jobs, you can set the default shell using Jenkins > Manage Jenkins > shell executable.
If you want to use csh for only a particular job, begin the Execute shell build step with a shebang, such as:
#!/usr/bin/tcsh -e -x
command1
command2
...
Since I have tested only tcsh, that is what I use in the example.
Beware that a space is not allowed after the #!:
#! /usr/bin/tcsh # Wrong
This will give the error,
java.io.IOException: Cannot run program ""
I tested the above on Jenkins 1.625.3