Jenkins multi string parameter printing strings in single line - jenkins

I am trying to create on freestyle project with multi string parameter. This will be built by user he have to input string values. Those strings will be embedded to file and pushed to s3 bucket. But the problem is whenever user trying to input multiple strings all the values are coming in single line.
user input
a
b
c
expected output:
a
b
c
Actual output i am getting
a b c

You can use the below while assigning multi-line value to a string:-
def a = """\
test
test
test""".stripIndent()
println(a);

sample parameters
I guess i figured it out.
printf '%s\n' "$tables_retained" > textfile1

Related

How to reverse the words in the string in automation anywhere

I am trying to reverse the string For Example string s= "Hello Robot Process Automation" will be changed to String s="Automation Process Robot Hello" in automation anywhere.
I tried below steps:-
Reverse the sentence(it reverses the words and alphabets in words as well).
2.Split the sentence and put into list variable
used loop and in same loop i reversed again the alphabets so now the sentence will be like "Automation" "Process" "Robot" "Hello" into one list
4 I am not getting next step after this(joining of these words).
Please help.
For reversing the string as per above requirement, below are the steps:
Create a variable for storing the reversed string called vReversedString
Reverse the given string i.e from above string the output should be noitamotuA ssecorP toboR olleH
Split the reversed string by space deliminator and store in my-list-variable
Loop through my-list-variable
Reverse the each element through the loop. For example, In this case the first element is noitamotuA by reversing this you'll be getting Automation as an output, store it to system variable clipboard or create a new variable to hold each element.
Concatenate and store to vReversedString = $vReversedString$ $clipboard$

FitNesse: Variable assignment and simple arithmetic

According to the user guide it is possible to assign values to variables and then perform simple arithmetic.
Imagine I have fixture designed to take an element on the page and extracting the numerical value as a Double (i do this now using the HSAC Slim BrowserTest fixture and my own code)
|script |numbers extraction |
|$testval1=|numeric value of |element1 | |
|$testval2=|numeric value of |element2 | |
Running this gives me something like:
|script |numbers extraction |
|$testval1<-[20.04]|numeric value of |element1 ->[€ 20,04] | |
|$testval2<-[5.1] |numeric value of |element2 ->[€ 5,1] | |
Now say I want to compare the sum of the two doubles with the numeric value of a third element:
|script|numbers extraction |
|check |numeric value of |element3|{=${ ${testval1} + ${testval2} =}|
No matter what combination of parentheses and dollar-signs I use in the last cell, I always get 'invalid expression'.
${= $testval1 + $testval2 =} invalid expression: $testval1 + $testval2
{${=$testval1 + $testval2 =}} {invalid expression: $testval1 + $testval2}
${=${testval1} + ${testval2} =} [invalid expression: undefined variable: testval1 + undefined variable: testval2]
${= !-$testval1-! + !-$testval2-! =} invalid expression: $testval1 + $testval2
${= !-${testval1}-! + !-${testval2}-! =} invalid expression: ${testval1} + ${testval2}
Running the last line (without parenthesis around testval1 and testval2) returns:
|check|numeric value of|element3 ->[€ 25.14]| [25.14] expected [invalid expression: $testval1->[20.04] + $testval2->[5.1]] |
Unfortunately you can can't do what you are looking for. The variables you assign the value of the elements to are actually SLIM symbols, and not variables at the wiki level. If you scroll a bit down on the user guide page you linked to in the question you will find a section called "Difference between variables and SLIM symbols":
Variables are evaluated at render time, before the test executes. This allows for values to be set based on page hierarchy and other things that are purely inputs to the tests.
Symbols only exist at execution time. They can be changed at runtime, so are distinct from variables, which cannot.
I find the three types of variables in FitNesse/SLIM are confusing to people and their different usage, syntax and possibilities cause many issues. My understanding is:
Markup variables (aka wiki variables). For instance ${myVar}, defined using !define. They get their value at page render time, so even before a test is started, so you see their value when you browse to a wiki page, and only in the page's source do you see it is a variable. These can be used in markup expressions, which is what you are trying to do in the question.
Scenario parameters. For instance #{myVar} (or #myVar), defined in the first row of a SLIM scenario table. These are the 'formal parameters' to the scenario, which get their actual value based on the invocation of the scenario (i.e. each usage of the scenario, either from a script table, other scenario or row in a decision table defines their value). They get their value at the start of a test, before its first action is performed. You see the variable when you look at the scenario table that defines it. (When you use the 'table template' table type defined by hsac-fitnesse-plugin (which is included in hsac-fitnesse-fixtures project baseline) you don't need to define the variable names in the first row of the table, they are automatically found based on their occurrence (e.g. #{myVar}) inside the table.)
SLIM symbols. For instance $myVar, they are assigned their value using $myVar=. These are 'runtime variables' that get their value during test execution, they are global to a test suite and their value might be changed during test execution. These are the only kind of variables that can get their value from a property obtained from the 'system under test', and they are the variables you are using in your question's tables. They are actually references to objects inside the SLIM process so fixtures might change the internal state of the object the variable refers to, without this change showing in the wiki representation of the variable (which is just the object's toString() result at time of last assignment).
P.S. The conversion of a string to a double does not require a custom fixture (like your numbers extraction) when you using the hsac-fitnesse-fixtures. You could just use the convert to double method of the library's string fixture.
You seem to be using browser test, this is an HSAC installation I take it? Please mention this in the question as HSAC is a FitNesse fixture.
Anyway, removing the curly brackets should do the trick. With curly brackets it is expecting a global variable, those that are implemented using !define var {foo}
When using variables that are locally defined such as with |$bar=|value of|foo| have to be called in the test using the variable without curly brackets.
|$bar=|value of|foo|
|enter|$bar|as|inputField|
Find more stuff on HSAC usage here: https://github.com/fhoeben/hsac-fitnesse-fixtures/wiki/2.-Slim-Fixtures
Sidenote:
Then there are also table templates that use #var or #{var}, where the use of #{var} is preferred because #{var} will look for the column var and #var will accept a column v or va, if you happen to implement that. Using curly brackets here ensures the full variable name is used.

How do we generate all parameter combination to form a URL

Suppose I have a url
xyz.com/param1=abc&param2=123&param3=!##
Each parameter can have many values like:
param1 = abc, xyz, qwe
param2 = 123, 456, 789
param3 = !##, $%^, &*(
All the parameters and values will be read from an excel file. There can be n number of parameters and each may have any number of values.
I want to generate all the combinations which can be formed using all values of each parameters.
Output will be like:
xyz.com/param1=abc&param2=123&param3=!##
xyz.com/param1=xyz&param2=456&param3=!##
xyz.com/param1=qwe&param2=123&param3=!##
xyz.com/param1=qwe&param2=456&param3=!##
xyz.com/param1=xyz&param2=789&param3=$%^
...
..
and so on
besides the previous comment in your post, you need construct some nested loops.
I will assume you have a bash shell available (since you hadn't specified your wanted language).
for I in 'abc' 'xyz' 'qwe'
do
for J in '123' '456' '789'
do
for K in '!##' '$%^' '&*('
do
echo "xyz.com/param1=${I}&param2=${J}&param3=${K}"
done
done
done
Note that:
that '&*(' will bring you problems, since & is the character that you use to delimit each parameter.
double quotes " around echo, will make a double quote character to make this program to fail miserably
the same apply to ', \ and some others

Retrieve value by variable name in erlang function

Is it possible somehow to retrieve variable value by its name (name represented as string)?
% we are calling foo function as foo(3)
foo(Param) ->
Var1 = Param * 2,
% some magic code here which can evaluate
% "Var1" string to Var1's value (6)
ok.
I want to implement (if it is possible) some kind of logger macro, like
Param = 3*4,
% This should write "My parameter value is 12" to log
?LOG("My parameter value is $Param").
Thanks.
The common way to log is to have formatting string and list of parameters. However your idea is achievable through usage of parse transform.
Thanks to Dmitry Belyaev for mentioning parse transform.
Say we have logging code:
?dump("My parameter value is $Param")
What I need here is to parse variables within format string ("My parameter value is $Param") with some regular expression. This format string contains single var name (Param). And we need to insert io_lib:format function call (by transforming original AST) with modified format string:
print_message(io_lib:format("My parameter value is ~p~n", [Param]))
In result we can archive required behavior:
Bar = "hello",
Buzz = buzz123,
?dump("Say $Bar to $Buzz"),
% => example:19: Say "hello" to buzz123
You can look at my implementation here
For toy problems you could use:
io:format("My parameter value is ~p~n", [Param]).
See io_lib and io.
Alternatively:
error_logger:info_report/1
or other error_logger functions.
The logging library lager is commonly used.

ColumnFixture Errors with variables

Having some issues with variables of format >>variableName<< within column fixtures in FitNesse. The language being used is C#. These errors are very similar to the parser error issue that was resolved recently. If anyone has any suggestions on how to go about solving the issue, or a resolution that would be great.
The specific issue is illegal characters in the table. variables in this format are not translated to their specific values... they are passed through as >>varName<<, with >> and << included.
The variable names wont work, instead try the following as an example.
First create a column fixture 'ShouldIncreaseCustomerCreditLimit' with input parameters AccountNumber and CreditLimit and output param CaseNumber.
Then create 'ShouldLoadCaseDetailsByCaseNumber' column fixture that takes input CaseNumber and output CreditLimit and AccountNumber.
In the wiki add the column fixture.
!|ShouldIncreaseCustomerCreditLimit |
|AccountNumber |CreditLimit|=CaseNumber?|
|0001011190301064616|1000 |>>casenumber|
!|ShouldLoadCaseDetailsByCaseNumber |
|CaseNumber= |CreditLimit?|AccountNumber? |
|<<casenumber|1000 |0001011190301064616|
Hope this helps.
Regards
Rustin

Resources