I am trying to run Testim via Jenkins. I am using windows batch command for run it
testim --host localhost --port 4444 --mode selenium --token "xxxxxxxxx" --project "xxxxxxxxxx" --params-file ".\testdata.js" --name=%test1% --name=%test2%
Here i am expecting the names of tests that i need to run as the value of variable 'name'. For eg. if i have, total of 10 tests, and the user select 2 or some tests out that 10, those 2 or that much number of test names should be the value of the variables test1,test2,test3...etc respectively . So that the number of tests selected by a user while bulding, that much number of times the variable 'name' should come with respective test names in build command.I have tried it with Active choice parameter plugin of Jenkins, but it gives an array and i am not able to take single element of that array in Build command.As i am new to this, Can anyone help me?
You can achieve this easily using a pipeline job, by converting the input string to the format you need.
Assuming you are using the Extended Choice parameter or similar, it will combine all selected values into a string, each value separated by your chosen separator.
Assuming your parameter is called Names and the separator is ',' you can use the following:
node {
def nameFlags = Names.split(',').collect { " --name=${it.trim()}" }
bat "testim --host localhost --port 4444 --mode selenium --token \"xxx\" --project \"xxx\" --params-file \".\\testdata.js\" ${nameFlags.join(' ')}"
}
Related
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.
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
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)?
env: Redis Cluster
Hi.
My requirement is:
Find value-B thought key-A (The process is use key-A find out value-A, the value-A == key-B, use key-B find out value-B )
my lua looks like this:
[root#ml-208 redis]# cat x-userid-tag.lua
local f3=redis.call('HGET',KEYS[1],'1'); local f4=redis.call('HGET',f3,'1') ; return f4;
my redis cmd:
./bin/redis-cli -c -h 192.168.33.203 -p 6000 --eval ./x-userid-tag.lua 0C559F3FEF368A8B53DE69C267423F0E
error msg:
(error) ERR Error running script (call to f_9bd20ba85f7bcc8ee1f6b55c4158bfa93eba2221): #user_script:2: #user_script: 2: Lua script attempted to access a non local key in a cluster node
Lua script runs on only one redis instance and its internal queries are not redirected by the cluster, So, it cannot query two keys if they are present in another cluster.
In your case, keyA and valueA(which is keyB) are hashed to different slots and to different nodes, so the lua will not work.
One way to fix it is to have the following as keys and value.
If you have a 'key1', and its value as 'value1', instead of keeping its value/key2 as 'value1', you should keep it as '{key1}:value1'.
Redis will make sure that both 'key1' and '{key1}:value1' are hashed to a single node, and you will be able to query both of them using lua.
I'm attempting to build, launch, and link a set of docker containers using Rundeck. In short (for those not familiar with docker), when an image is launched, it returns a container ID. I would like to use this container ID in the launching of subsequent jobs.
When run from the command line, it would look something like this (example only!!):
# docker run -Pd 23ABCD45
34DEF123
# docker run -Pd --link 34DEF123:host1 ABC123EF
321CB456
(note the use of the first return value in the second command line)
At this point, there would be two containers running. The second would be linked to the first by the --link option, and it would be addressable using the hostname host1 from inside the second container. To be fair, docker generates (or may be given) a specific container name which can be used in place of the container id. I would prefer to use the container ID to avoid the hassle of having to create/track unique names.
I would like to be able to capture the output of the first command (the container ID) so that it can be reused in the second command. Is this possible?
Edit: These images are being used for testing immediately following a
"docker build" (which also outputs a similar ID I would like to
include in my chain) and might be followed by "docker rm" and "docker
rmi" commands, so there are a number of uses for capturing this type
of output and carrying it through a related set of operations. This
is not just about launching/linking containers.
There is no direct Rundeck implementation that allows you pass an output from one job to another job as an input, but there are work around I've tried in the past, and I've settled on the second approach.
1. Use a file to pass data
Save the ID/output into a tmp file in first job
Second job read that file
Things might go wrong since you depend on a file, but good code can improve.
2. Call two jobs using Rundeck CLI from another job
This is the approach I am using.
JobA printout two random numbers.
echo $RANDOM;echo $RANDOM
JobB print out the second random produced from JobA which is passed as an option "number"
echo "$RD_OPTION_NUMBER is the number JobB received"
JobC calls first job, save last line to a variable and pass it to JobB
#!/bin/bash
OUTPUT_FROM_JOB_A=`run -f --id <ID of JobA> | tail -n 1`
run -f --id <ID of JobB> -- -number $OUTPUT_FROM_JOB_A
Output:
[5394] execution status: succeeded
Job execution started:
[5395] JobB <https://hostname:4443/project/Project/execution/show/5395>
6186 is the number JobB received
[5395] execution status: succeeded
This is just primitive code sample. you can do alot with python subprocess or just use bash.