I did following to install jenkins on my Mac for a ruby on rails project with a rspec test suite
1- installed with brew
2 - started jenkins and installed git/rake/rvm plugins
3 - managed to run bundle exec spec after installing rails in "/Users/me/.jenkins/workspace/myp-project"
4 - But I am getting an error while running a build on jenkins interface
$ bundle exec rake spec
FATAL: rake execution failed
java.io.IOException: Cannot run program "bundle"
(in directory "/Users/me/.jenkins/workspace/my-project"): error=2, No such file or directory
any pointers how can I fix this ?
I recently faced the same issue
When running from Console everything is ok , when running from execute shell all is alright when in Jenkins the Jenkins-man simply could not execute "gem" or "bundler" or X sample :
18:20:40 Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "bundler" (in directory "/home/builder/lcg-qa-jenkins-slave/workspace/delete_me2/target/src/main"): error=2, No such file or directory
18:20:40 around Ant part ...<exec failonerror="false" dir="target/src/main" executable="bundler">... # 78:76 in /home/builder/lcg-qa-jenkins-slave/workspace/delete_me2/target/antrun/build-main.xml
The error is totally misleading as the files do exist but for some weird reason cannot pick up executable stuff from /.rbenv/shims.
I tried uninstalling - reinstalling through numerous official and unofficial rbenv or rvm and each time got the same issue with Jenkins.
Note that this only occurs on Jenkins when Jenkins is executing while works perfect when actually running from the actual Jenkins slave or running localy.
My issue is solved with getting those executables with simlinks to /usr/bin
So when you see jenkins doing the I cant execute thingy.. then symlink the executables:
sudo ln -sfn /home/builder/.rbenv/shims/bundler /usr/bin/bundler
None of the below additions to the 'execute shell' in Jenkins had any effect at all when previous tries:
##!/bin/bash
#export PATH=$PATH:/usr/local/bin:$HOME/.rbenv/bin:$HOME/.rbenv/shims
#eval "$(rbenv init -)"
#rbenv local
#rbenv rehash
#export PATH="$HOME/.rbenv/shims:$PATH"
#echo "$PATH"
#echo 'source "/etc/profile.d/rvm.sh"' >> ~/.bashrc
#echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
Related
I am trying to run python test through jenkins. I have pytest framework.
I have also installed python 3.8 on jenkins slave machine and set path in the environment variables
I have added below path under PATH section of environment variable as below
C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\Scripts
C:\Users\Admin\AppData\Local\Programs\Python\Python38-32
But still I am getting below error on while running job.
Below are my windows batch command to run from Jenkins:
echo '#### Create Virtual Environment ####'
python -m venv .UIAutomation/venv
echo '#### Activate Virtual Environment ####'
echo '#### Run tests ####'
pytest -s -v --alluredir=.UIAutomation/reports ./UIAutomation/tests --env=staging --browser=chrome
Please help
More details about console error :
warning: manifest_maker: standard file '-c' not found
12:04:12 Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
Note:
Below is my first requirement from file
Collecting psycopg2==2.8.6 (from -r ./UIAutomation/requirements.txt
So after execution I am seeing below error at first line of console-
12:04:12 Error: pg_config executable not found.
12:04:12 pg_config is required to build psycopg2 from source. Please add the directory
From what I see, I find the batch call suspicious.
I think call launches a new console and returns to the script, if its done. So in your case, you activate your venv in another console and then use your standard python env, not the venv and there is no pytest dependency installed.
See also: https://ss64.com/nt/call.html
I had a similiar problem in a yaml script I wrote for Azure DevOps.
I did solve that, with creating the venv and then adding the venv path to the environment variables.
I'm wrote a script to automatically run when reboot on crontab
this is my configuration in crontab -e
#reboot /home/deploy/startup_script >> /home/deploy/startup_script.log 2>$1
This start the script and create logs in /home/deploy
Then this is the startup_script
#!/bin/bash
echo "Changing directory"
cd /home/deploy/source/myapp
echo $PWD
echo "Pulling Dev Branch..."
git pull origin dev_branch
echo "Running Bundle Install"
sudo gem install bundler
bundle install
echo "Deploying to Staging..."
bundle exec cap staging deploy
when I run this script manually using ./startup_script it runs properly but when I run it automatically in crontab it shoes bundle command not found even I install the bundler already.
Here's the logs from startup_script.log
Changing directory
/home/deploy/source/myapp
Pulling Dev Branch...
From ssh://1.xx.xx.xx.io:20194/xx/myapp
* branch dev_branch -> FETCH_HEAD
Already up-to-date.
Running Bundle Install
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Done installing documentation for bundler after 5 seconds
1 gem installed
/home/deploy/startup_script: line 12: bundle: command not found
Deploying to Staging...
/home/deploy/startup_script: line 15: bundle: command not found
The cron often clears the whole environment, including this $PATH variable. Therefore, the script may behave differently in your cron compared to the behavior in the shell. To avoid having to type the absolute path to a command, shells introduced the $PATH environment variable, each directory is separated by a : and searches are done from left to right.
Option I: You can use absolute path:
Run which bundle as sudoer to get the full path for the bundle command. If the output is /usr/bin/bundle, your bundle command in the script would look like:
/usr/bin/bundle install
Option II: Set the PATH variable:
Run echo "$PATH" as user who runs this script to get the $PATH variable and make sure this variable is available in your cron script too. For example, if the output was /usr/local/bin:/usr/bin:/bin, you would put the below line in the top of your shell script:
export PATH="/usr/local/bin:/usr/bin:/bin"
The environment that your crontab uses is going to be different than your regular login shell.
Now, I might be wrong about this, but I think when the crontab executes, it's not a login shell, so it doesn't have anything you've added to your path in your .bashrc or .bash_profile.
The best practice here would be to use the full path of the executable for bundle.
Redirecting stderr to stdout, there should be 2>&1
Is the path where the gem packages are installed is added to the $PATH variable? Try to provide the full path to this script
I suggest you make an entry to see what environment variables you have for crontab:
* * * * * printenv > ~/printenv.log
I have the following execute script on my CI environment
cd /var/www/html
php vendor/bin/phpunit app/tests --log-junit /var/lib/jenkins/jobs/Closecall/workspace/tests/reports/junit.xml
php vendor/bin/phinx migrate -e development
sudo compass compile
SSHing onto the CI and compiling myself works fine, however when the CI executes this on build I get the following error
+ sudo compass compile
sudo: no tty present and no askpass program specified
Build step 'Execute shell' marked build as failure
Recording test results
Finished: FAILURE
Any ideas?
sudo by default tries to open /dev/tty for read-write. You might not have /dev/tty available on the machine you use to build. The need for tty is configured in the /etc/sudoers file.
sudo has an option -S to read the password from standard input instead of /dev/tty. You should be able to compile using sudo -S.
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
http://linux.die.net/man/8/sudo
I am trying to create a tiny shell script that will deploy a Rails app by first rsync'ing, then running the bundle command remotely via ssh. My shell script looks like this:
#!/bin/bash
REMOTE_SERVER="myserver.com"
REMOTE_USER="me"
REMOTE_PATH="/home/me/"
BUNDLE_PATH="/usr/local/rvm/gems/ruby-2.0.0-p353/bin/bundle"
# Step 1: Rsync
rsync -ave ssh --exclude-from '.ignore' ./ $REMOTE_USER#$REMOTE_SERVER:$REMOTE_PATH
# Step 2: Bundle
ssh $REMOTE_USER#$REMOTE_SERVER "cd $REMOTE_PATH && $BUNDLE_PATH install"
Rsync'ing works fine but when RVM is involved, the bundle line throws the following error:
/usr/bin/env: ruby_executable_hooks: No such file or directory
So, I'm wondering ... Is it possible to run the bundle (and other commands like rake) as part of a single ssh command?
If it matters, the remote server is running Ubuntu 14.
This problem has already been solved by the community. It's called Capistrano.
http://capistranorb.com/
i got this method inside recipe
script "bashbashed" do
interpreter "bash"
user "root"
code <<-EOH
cd /my/path
ant clean
ant build
ant deploy
EOH
end
returns
localhost STDERR: /tmp/chef-script20131004-5434-823zxp: line 1: cd: tarball: No such file or directory
localhost /tmp/chef-script20131004-5434-823zxp: line 4: ant: command not found
localhost /tmp/chef-script20131004-5434-823zxp: line 5: ant: command not found
localhost /tmp/chef-script20131004-5434-823zxp: line 6: ant: command not found
login to guest and do ant -version.
ant is installed in the guest. am i still missing something here?
The error messages indicate 2 problems:
the path /my/path does not exist.
it does not contain path to your java ant installation in $PATH.
An updated version:
script "bashbashed" do
interpreter "bash"
user "root"
cwd "/my/path" # make sure this path exists
path "#{ENV['PATH']}:/opt/ant/bin" # customize to the location of your ant command
code <<-EOH
ant clean build deploy
EOH
end
Your problem is that the environment files supplied under "/etc/profile.d/*" are not sourced by the root user, this would explain why your bash script (running as root) does not have ant configured in its path.
Perhaps a simple solution would be to run the build as a normal user account?