Error executing Ruby in Jenkins - ruby

I'm running Jenkins ver. 1.537 on Win7 64.
I'm trying to run a Ruby script in Jenkins using the "Execute Ruby script" build function.
The command is C:/autotest/Ultrapos_FX2-3/lib/testout.rb.
The script I'm trying to run is a simple hello world type thing:-
begin
puts 'TEST OUTPUT'
end
I can run this sucessfully from the command prompt, but Jenkins gives me the following error:-
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\ruby\workspace
[workspace] $ ruby -v C:\Users\ithomp\AppData\Local\Temp\hudson8549990801552818192.rb
ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
C:/Users/ithomp/AppData/Local/Temp/hudson8549990801552818192.rb:1: syntax error, unexpected tIDENTIFIER, expecting end-of-input
C:/autotest/Ultrapos_FX2-3/lib/testout.rb
^
Build step 'Execute Ruby script' marked build as failure
Finished: FAILURE
It seems that Jenkins is not executing the script that I'm specifing and instead calling some temp file.
Any ideas as to what the issue is?.
Thanks.
Ian.

Related

When running an application under ruby 2.3.1 using the rails server command, the following error occurs: can not modify a frozen array (RuntimeError)

I have to run an application developed in Ruby on rails. ruby 2.3.1 and rails 4.2.0
When I execute the rails server command. I get the following error:
.... config / initializers / doorkeeper.rb: 75: in <top (required)>: can not modify a frozen array (RuntimeError).
Can I explain how to succeed to no longer have this error, thank you
Info :
The "bundle install" command runs successfully.
The code around doorkeepee.rb near line 75 : Doorkeeper.configuration.token_grant_types << "password"
I'm trying to understand how RAIL_ENV works. Can you help me at the same time?

Install a particular Ruby version using chef-run

I have been trying to install a particular (latest) version of Ruby using Chef Workstation and its included chef-run CLI.
This is the recipe I'm using for Ruby:
package 'ruby' do
version '2.5.3'
action :install
end
Which, running with the command line
chef-run -i /path-to/private_key user#host ruby.rb
Produces the not very helpful message:
[✔] Packaging cookbook... done!
[✔] Generating local policyfile... exporting... done!
[✖] Applying ruby from ruby.rb to target.
└── [✖] [127.0.0.1] Failed to converge ruby.
The converge of the remote host failed for the
following reason:
Expected process to exit with [0], but received '100'
I have tried to run it with the -V flag, or look for a log file, but I can't seem to find it. Any idea?
raise the log_level by setting it to debug in the chef-workstation configuration
$ cat ~/.chef-workstation/config.toml
[log]
level="debug"

Is there a reliable Command Line or Powershell step format to run RSpec tests on TeamCity?

We are experimenting with using RSPec for our UI tests and noted that while attempting to integrate these with TeamCity we end up with environment related errors. The problem is that when we run these tests locally on the build server they run without any errors.
We are trying to execute the login test within a working directory located on the build server with a Command Line or Powershell:
cd D:\web_smoke_tests-master
gem install bundler
rake cloud:chrome
We are returning the following error in our build log despite the environment containing all of the ruby dependencies. Note that this is a windows build server / build agent.
[21:31:30]Step 3/5: Execute login test (Command Line)
[21:31:30][Step 3/5] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script #edited out
[21:31:30][Step 3/5] in directory: D:\web_smoke_tests-master
[21:31:30][Step 3/5] 'gem' is not recognized as an internal or external command,
[21:31:30][Step 3/5] operable program or batch file.
[21:31:30][Step 3/5] 'rake' is not recognized as an internal or external command,
[21:31:30][Step 3/5] operable program or batch file.
[21:31:30][Step 3/5] Process exited with code 1
[21:31:30][Step 3/5] Step Execute login test (Command Line) failed
Regarding the above. This was due to the user containing the build agent not having any ruby dependencies installed and as a result "gem" or "rake" were not recognized.

How can you tell if running a command through the heroku cli succeeded?

When running a command through heroku, such as:
heroku run rake db:migrate
I would like to know if the command succeeded or not. Unfortunately, even if running the migration fails, I get an exit status of 0.
I'm writing some ruby code that wraps this command and invokes it, and raises an error if the command failed. The code looks like:
Open3.popen2e('heroku run rake db:migrate') do |stdin, stdout_and_stderr, wait_thr|
raise 'running migration failed' unless wait_thr.value.success?
end
Even when running this fails, and I get a message:
rake aborted! StandardError: An error has occurred, this and all later
migrations canceled:
My code itself does not raise an error. Inspecting wait_thr.value in the above code, it has an exit code of 0, which means the heroku CLI believes the rake call succeeded.
How can my code know if the command that was run by the heroku cli failed? Is there a way to tell the heroku CLI to return the status code of the command it ran?
There is now official support for this from their CLI:
heroku help run
Usage: heroku run COMMAND
run an attached dyno
-s, --size SIZE # specify dyno size
--exit-code # return exit code from process
So you would now run:
heroku run --exit-code rake db:migrate
You're not alone with this. Many have complained about this before, check this out:
https://github.com/heroku/heroku/issues/186
You can (dirty) work around the problem with this gem:
https://github.com/glenngillen/heroku-exit-status

Compass only running in parts

As i am trying to get my version on the command line by typing:
compass -version
I am receving the following error:
Errno::ENOENT on line ["25"] of /usr/lib/ruby/vendor_ruby/compass/version.rb: No such file or directory - /usr/lib/ruby/vendor_ruby/compass/../../VERSION.yml
Run with --trace to see the full backtrace
Apart from that everything is running fine.
Anyone with the same problem, a workaround, a solution ?
This is a reported and confirmed bug: https://bugs.launchpad.net/ubuntu/+source/ruby-compass/+bug/1100018

Resources