Setting up a rake task to run a specific Cucumber scenario - cucumber

I'm trying to set up a rake task to run any cucumber scenario with a certain tag(#server).
I have a rakefile in the root of the project directory with this code:
require 'cucumber/rake/task'
desc "Get SQL response and store it in a file"
Cucumber::Rake::Task.new(:server, 'Execute SQL (#server only)') do |t|
t.cucumber_opts = [ '--tags', '#server' ]
end
task :default => :server
With a cucumber.yml file for default profile in the root of the project as well
default: --profile server_cache
server_cache: --format pretty --tags #server
I try running "jruby -S rake" on the command prompt while in my project folder and I get this error:
"'jruby.bat.exe' is not recognized as an internal or external command, operable program or batch file"
Am I trying to run the task in a wrong way?
I'm using jruby 1.5.6, version 1.8, on windows xp.
Thanks in advance for any help!

I would have posted this as a comment, but your problem has nothing to do with rake, and everything to do with gem installation
I'm curious, are you using RubyMine? I've had this problem before when I installed gems for jruby using RubyMine's installer. For whatever reason, it munges the batch files during installation of gems.
For example, your rake.bat file should look something like this:
#ECHO OFF
#"%~dp0jruby.exe" -S rake %*
If it doesn't, it's probably been updated by your gem install process.
You're executing the command correctly, but something has munged the rake.bat (or cucumber.bat, check it as well) to include an execution of 'jruby.bat.exe' when it should just call jruby.exe For reference, my cucumber.bat looks like this:
#ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
#"jruby.exe" "C:/<path to jruby>/bin/cucumber" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
#"jruby.exe" "%~dpn0" %*

Related

Use BATCH file to call NodeJS script in a password protected folder

I am trying to use a batch file to call a node script. The node script exists on a server which is password protected. How do I both call the node script and include the credentials for the path in the same batch file?
Script looks like this
CLS
#ECHO OFF
node "\\[server_name]\d$\[path_name]\GetDynamicTeams.js"
if NOT %ERRORLEVEL% == 0 (
pause
)
I have tried running the net use syntax and included the user/pass but to no avail. That looked like this
node net use "\\devwn12281\d$\xMattersSystems\scripts\xMatters Toolbox\GetDynamicTeams.js" /USER:alarmpoint xm2215x99=
Syntax wouldn't work because I can't include node keyword in that command.
Any ideas?

Azure batch job start tasks failed

I'm using Azure batch python API. When I'm creating a new job, I see exit code 128 (image attached). How can I know what is the reason for that?
I'm creating a new job using this code :
def wrap_commands_in_shell(commands):
return "/bin/bash -c 'set -e; set -o pipefail; {}; wait'".format(';'.join(commands))
job_tasks = ['cd /mnt/batch/tasks/shared/ && git clone https://github.com/cryptobiu/OSPSI.git',
'cd /mnt/batch/tasks/shared/OSPSI && git checkout cloud',
'cd /mnt/batch/tasks/shared/OSPSI && cmake CMake',
'cd /mnt/batch/tasks/shared/OSPSI && mkdir -p assets'
]
job_creation_information = batch.models.JobAddParameter(job_id, batch.models.PoolInformation(pool_id=pool_id),
job_preparation_task=batch.models.JobPreparationTask(
command_line=wrap_commands_in_shell(
job_tasks),
run_elevated=True,
wait_for_success=True
)
)
To diagnose, you can look at the stderr.txt and stdout.txt for the Job Preparation task that has failed in the Azure Portal, using Azure Batch Explorer, or using an SDK via code. If you look at which node ran the job prep task, navigate to that node, then the job directory. Under the job directory, you should see a jobpreparation directory. In that directory will have the stderr.txt and stdout.txt.
With regard to the exit code, there are a few potential problems that could cause this:
Did you install git, cmake and any other dependencies as part of a start task?
I get a 404 when I try to navigate to: https://github.com/cryptobiu/OSPSI. Does this repo exist? If it's a private repository, are you providing the correct credentials?
A few notes about your job_tasks array:
You should not hardcode the paths /mnt/batch/tasks/shared. This path to the "shared" directory may not be the same between Linux distributions. You should use the environment variable $AZ_BATCH_NODE_SHARED_DIR instead. You can view a full list of Azure Batch pre-filled environment variables here.
You do not need to cd into the directory for each command, you only need to do it once. You can rewrite job_tasks as:
['cd $AZ_BATCH_NODE_SHARED_DIR',
'TODO: INSERT YOUR COMMANDS TO SETUP AUTH WITH GITHUB FOR PRIVATE REPO',
'git clone https://github.com/cryptobiu/OSPSI.git',
'cd OSPSI',
'cmake CMake',
'mkdir -p assets']

Selenium testing with Jenkins

I have been trying to start selenium tests with browsers, not headless. I have my code in SVN and this should be build by Jenkins. Jenkins is on Linux.
Has anyone ever tried that or do you know what steps I should take? I am going through tutorials available on the internet but none of them work for me.
My current error is:
java.io.IOException: Cannot run program "cmd" (in directory
"/var/lib/jenkins/jobs/Tests/workspace"): error=2, No such file or
directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at hudson.Proc$LocalProc.(Proc.java:240) at
hudson.Proc$LocalProc.(Proc.java:212) at
hudson.Launcher$LocalLauncher.launch(Launcher.java:815) at
hudson.Launcher$ProcStarter.start(Launcher.java:381) at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:95)
at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:64)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205) at
hudson.model.Build$BuildExecution.doRun(Build.java:162) at
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1720) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at
hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410) Caused by:
java.io.IOException: error=2, No such file or directory at
java.lang.UNIXProcess.forkAndExec(Native Method) at
java.lang.UNIXProcess.(UNIXProcess.java:187) at
java.lang.ProcessImpl.start(ProcessImpl.java:130) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1028) ... 15 more
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
When built without error, the workspace was only updated:
Building in workspace /var/lib/jenkins/jobs/Tests/workspace
Updating http://XX.XX.XXX.XX/resp/extend/Tests/EO at revision '2016-07-04T14:34:05.110 +0200'
At revision 5536
No changes for http://XX.XX.XXX.XX/resp/extend/Tests/EO since the previous build
Finished: SUCCESS
If you need any further details, let me know ...
UPDATE:
[workspace] $ /bin/sh -xe /tmp/hudson8771943326851387647.sh
+ ./script.sh
/tmp/hudson8771943326851387647.sh: line 2: ./script.sh: Permission denied
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I have changed the windows command to shell command. The shell command is:
./script.sh
I think that the script inside the file i wrong, but does the error I have now mean that the script is wrong or does it reflect to something else? I do not know hwy we have "permission denied" - I have all the right in jenkins.
And this is my script.sh file content:
#!/bin/bash
function run_test {
echo "=== run Selenium tests in Jenkins ==="
ssh root#$1 "/src/test/java/mainTest/MainOrderTest start"
}
fi
I have no knowledge on shell command and I have not found any command that would run this program.
You are trying to run windows batch scripts on Linux hence the error.
Two options :
1. Either convert your build scripts to shell and use "execute shell" to call your shell scripts in jenkins
2. Add a windows slave which will build your windows batch script

R Command not recognized when submitted with SSH

I am submitting a shell script on a remote host that in turn submits an R script, but the error R: command not found or Rscript: command not found (depending whether I tried R CMD BATCH or Rscript).
I have tried submitting in the following ways:
ssh <remote-host> exec $HOME/test_script.sh
ssh <remote-host> `sh $HOME/test_script.sh`
The script test_script.sh contains (have tried Rscript as well):
#!/bin/sh
Rscript --no-save --no-restore $HOME/greetme.R
exit 0
The script greetme.R contains only cat("Hello\n").
The reason I am getting flustered is that when I log into the remote-host and submit the original script with sh $HOME/test_script.sh, it runs as intended.
The system specs and R versions for both the local and remote hosts are identical:
> R.version
_
platform x86_64-unknown-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 1.0
year 2014
month 04
day 10
svn rev 65387
language R
version.string R version 3.1.0 (2014-04-10)
nickname Spring Dance
Why is Linux refusing to recognize the commands?
I would prefer solutions using R CMD BATCH or Rscript but if there are known workarounds using littler or %R_TERM% I would like to hear them too.
I used this related question as reference, as well as the documents referenced in the comments: R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference?
EDIT for solution:
As #merlin2011 suggested, once I specified the full path in the test_script.sh, everything worked as intended:
#!/bin/sh
/opt/R/bin/Rscript --no-save --no-restore $HOME/greetme.R
exit 0
I got the path also by the provided suggestion:
$ which Rscript
/opt/R/bin/Rscript
It appears that you have a PATH issue, where R is not on your PATH when you try to run the command through ssh.
If you specify the full path to R and Rscript on the remote host, it should resolve the problem.
If you are not sure what the full path is, try logging into the server and running which R to get the path.

TortoiseProc CruiseControl.NET: Unable to execute file problem

I am new to CruiseControl and automated build. My problem is that the ccnet service always promt me "unable to execute file TortoiseProc.exe /command ...". My config file looks like this
TortoiseProc.exe /command:update /path:C:\Work\global.ad.lib.objectmanagement /closeonend:1
This command(tortoiseProc....) works well in a CMD window. The Ccnet service is execute with an Admin account. "C:\Program Files\TortoiseSVN\bin" is in the environnement variables and can be executed from anywhere. If i force a build from the Dashboard, it builds perfectly. I have the feeling this is just a simple stupid thing...
Tks
You will need to specify TortoiseProc.exe parameters separately from the executable name, inside "buildArgs" element. Here is the right ccnet.config fragment for your situation:
<exec>
<description>Execute TortoiseProc.exe</description>
<baseDirectory>c:\path\to\tortoiseproc\folder</baseDirectory>
<executable>TortoiseProc.exe</executable>
<buildArgs>/command:update /path:C:\Work\global.ad.lib.objectmanagement /closeonend:1</buildArgs>
</exec>
Also you can create cmd-file with your commands and use exec without parameters, if that would be easier for you.

Resources