How to injecting jenkins variable to robot script report name - jenkins

I have a text file on my linux machine which stores a integer value. I want that integer value to be in my robot results report file.
I tried this:
${FILE,path="/home/ubuntu/Build_number.txt"}
and its properly printing the integer in email content of jenkins but when I give it in robot command (which is on execute shell in jenkins), it does not print any value.
Robot command as:
robot -r report_${FILE,path="/home/ubuntu/Build_number.txt"} Login.robot
Actual: Running this command generates a report file of name report_.html
Expected:
report_(integer value in Build_number.txt)

Indeed, this question to Linux/Bash forum. Bash has another syntax what you use.
Correct command is:
robot -r report_$(cat /home/ubuntu/Build_number.txt) Login.robot

Related

Ansible Tower CLI pass Launch Parameters in one command without prompt

I am trying to launch an ansible-tower cli job through Jenkins. But I don't want a prompt that appears on Ansible Tower. I want to pass those parameters in the same command so that a prompt is not required.
I have tried:
tower-cli job launch --job-template=33 -e "param1" -e "param2"
This is the error I get:
Error: failed to pass some of the extra variables
According to the Ansible Tower-CLI documentation the parameter -e is wrong. You need to use --extra-vars. This differs from ansible-playbook command. So an easy example is
tower-cli job launch --job-template 1 --extra-vars '{"x":"y"}'
Be aware that you write all vars in one argument. The --extra-vars expects JSON or YAML format.
Be also aware, that the given job template MUST be configured to ask for extra-vars. Otherwise the argument is ignored on Ansible Tower side.
Also - not the question but a good advice - if your Jenkins needs to wait for the job result add --monitor to the tower-cli command. Then the cli waits for the response code and the stage could "fail" if there is a problem.

Jenkins integration with JMeter - build is failed giving **Error: Unable to access jarfile ApacheJMeter.jar errorlevel=1**

Jenkins Cosole output :updated 2
When executing the Jmeter .JMX file using JMeter non GUI mode, it is working fine and I am able to get the .JTL file, but when I am trying to trigger the build using Jenkins it is getting failed giving Error: Unable to access jarfile ApacheJMeter.jar
errorlevel=1 as message from console output .
Please note that I have added Perfomance Plugin in Jenkins and made jmeter.save.saveservice.output_format=xml enabled in JMeter user properties. Please help if I am missing anything to setup the configuration.
Build cmd command
C:\jmeter\bin\jmeter -J jmeter.save.saveservice.output_format=xml -n -t C:\jmeter\bin\edueka.jmx -l C:\jmeter\bin\report3.jtl
code from CMD - JMeter non GUI
JMeter Jar file access from CMD
There is nothing wrong with your command, it should work normally.
Double check that the main JMeter executable .jar exists and the user which executes Jenkins process has correct permissions to access this file:
c:\jmeter\bin\ApacheJMeter.jar
The most common mistake is that users download source bundle of JMeter instead of the binary
Also the correct syntax for passing JMeter Properties via -J command line argument is:
J needs to be capital
remove the space between J and the property name
C:\jmeter\bin\jmeter -Jjmeter.save.saveservice.output_format=xml -n -t C:\jmeter\bin\edueka.jmx -l C:\jmeter\bin\report3.jtl
Also currently there is no need to switch JMeter results format to XML, Jenkins Performance Plugin is capable of processing JMeter results files in .CSV format as well

Using Revision Variable in Docker Build Step

Trying to use the $(Rev:.r) variable in my docker build steps (version 1.*) for tagging and it doesn't seem to work. I always get
2019-01-14T21:42:24.4149933Z ##[error]invalid argument
"wp/imagename:0.6$(rev:.r)" for "-t, --tag" flag: invalid reference
format 2019-01-14T21:42:24.4160700Z ##[error]See 'docker build
--help'. 2019-01-14T21:42:24.4274219Z ##[error]/usr/bin/docker failed with return code: 125
No variable substitution seems to be happening and it looks like it's running it through with the Qualify image name option and lower-casing the R. Can anyone else use the $(Rev:.r) variable?
Doesn't matter where I try using that variable, i can use it in the Image Name option or the Arguments option and it gives me the same error.
-t wp/imagename:0.6$(Rev:.r)
You can't get just "the revision number" without parsing, it is not stored as a separate field somewhere. The $(Rev:.r) portion instructs Azure DevOps to come up with the first number that makes the build number unique (and, in that specific example, put a dot in front of it). Only the final build number is available.
At workaround, add a the $(Rev:.r) in the end of your build number (if it not there). add a PowerShell script task (you can do it inline PowerShell) before the Docker task and put this code:
$buildNumber = $Env:BUILD_BUILDNUMBER
$revision= $buildNumber.Substring($buildNumber.LastIndexOf('.') + 1)
Write-Host ("##vso[task.setvariable variable=revision;]$revision")
In your docker use the $revision variable:
-t wp/imagename:0.6$(revision)
I've only been able to get it to be recognized in the Build number format section under options.
If you are using this like a build number, why not just set the build number there instead and then reference using $(Build.BuildNumber)?

What command should I be using to launch a program from the Lua Intepreter?

I have been attempting to troubleshoot how to launch a program I write in Lua, and it seems to me that I should be launching the program from the Lua Interpreter. The First Edition of Programming in Lua tells me I should use the command prompt> lua hello.lua. The name of my program is "hello.lua" and it is in the same folder as the Interpreter but I get the error message '=' expected near '>'. What command should I be using? Or am i doing something wrong?
Under Windows (administrator console):
ftype Lua.File=C:\utils\lua.exe "%1" %*
(where c:\utils\lua.exe is the actual path of your Lua interpreter)
assoc .lua=Lua.File
Now, you can type: hello.lua directly at the command prompt
And, if in "Computer/Properties/Advanced/Environment Variables" (Win7 example) you add .LUA to the PATHEXT variable, you can simply type: hello at the command prompt, without the extension.
(I guess you are on some Unix or POSIX system)
Just type lua hello.lua; the prompt> string is given by your shell (and the prompt is generally something different and configurable).
By typing literally prompt> you are asking your shell to run a program -or a command- named prompt and to redirect its stdout (to what follows the >)

Jenkins shell command work flow

Under the link http://docs.buildbot.net/latest/manual/cfg-buildsteps.html#shellcommand,
in the shell command it states that
On Windows, commands are run via cmd.exe /c which works well. However, if you're running a batch file, the error level does not get propagated correctly unless you add 'call' before your batch file's name: cmd=['call', 'myfile.bat', ...].
It says that the commands are executed cmd.exe.
I assume the cmd.exe is located in the c:\windows\system32\cmd.exe, am i right or it calls from some other location like in the windows startup .
The cmd.exe is the one found in the system path variable PATH for the Jenkins process. On my machine it is in C:\windows\system32\cmd.exe.

Resources