Jenkins: send multiple params in URL trigger - jenkins

I have a Jenkins job which checks a file version...
This project is parameterized:
Multi-line String Parameter = server
Powershell command
$servers = ($env:servers).Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries)
foreach ($server in $servers) {ls "\\$server\c$\update.dll" | % versioninfo}
I trigger it using the URL:
http://MY_JENKINS_SERVER/job/FILE_VERSION/buildWithParameters?servers=10.10.10.1
it works and I get:
ProductVersion FileVersion FileName
-------------- ----------- --------
11.1.1.16 11.1.1.16 \\10.10.10.1\c$\update.dll
But I want to send multiple IP's in the trigger URL, eg
10.10.10.1
10.10.10.2
10.10.10.7
So I output something like:
ProductVersion FileVersion FileName
-------------- ----------- --------
11.1.1.16 11.1.1.16 \\10.10.10.1\c$\update.dll
11.1.1.15 11.1.1.15 \\10.10.10.2\c$\update.dll
11.1.1.15 11.1.1.15 \\10.10.10.7\c$\update.dll
Anyone know how?

Since you are using "Multiline String Parameter", you will have to provide all the required values separated by newline character. Generally, \n is considered for newline, however, you will have to "url-escape" it. Use this %0A as newline character.
So, your POST URL should be something like this :
curl -v -X POST <jenkins_url>/<job_name>/buildWithParameters?server=11.1.1.16%0A11.1.1.15%0A11.1.1.15
More reference on url-escape characters : https://www.w3schools.com/tags/ref_urlencode.asp

Related

Rascal: parsing string with multiple "_"s

I try to parse a string containing multiple "_"s, but I get a CallFailed exception.
I have tried to create a small as possible example of the problem syntax.
layout Layout = WhitespaceAndComment* !>> [\ \t\n\r#];
lexical WhitespaceAndComment = [\ \t\n\r] | #category="Comment" "#" ![\n]* $;
syntax SourceList = sourceList: "$"? "{"? Id sourceFile "}"?;
lexical Id = ([a-zA-Z/.\-][a-zA-Z0-9_/.]* !>> [a-zA-Z0-9_/.]) \ Reserved;
keyword Reserved =
"$" | "{" | "}" ;
I am unable to parse this small example.
rascal>try { parse(#SourceList, "test"); } catch CallFailed(m, e): println("<m> : <e>");
|prompt:///|(25,9,<1,25>,<1,34>) : [type(sort("SourceList"),(sort("SourceList"):choice(sort("SourceList"),{prod(label("sourceList",sort("SourceList")),[opt(lit("$")),layouts("$default$"),opt(lit("{")),layouts("$default$"),label("sourceFile",lex("Id")),layouts("$default$"),opt(lit("}"))],{})}),layouts("$default$"):choice(layouts("$default$"),{prod(layouts("$default$"),[],{})}),empty():choice(empty(),{prod(empty(),[],{})}),lex("Id"):choice(lex("Id"),{prod(lex("Id"),[conditional(seq([\char-class([range(45,47),range(65,90),range(97,122)]),conditional(\iter-star(\char-class([range(46,57),range(65,90),range(95,95),range(97,122)])),{\not-follow(\char-class([range(46,57),range(65,90),range(95,95),range(97,122)]))})]),{delete(keywords("Reserved"))})],{})}),keywords("Reserved"):choice(keywords("Reserved"),{prod(keywords("Reserved"),[lit("$")],{}),prod(keywords("Reserved"),[lit("}")],{}),prod(keywords("Reserved"),[lit("{")],{})}))),"${test}"]
ok
A changed sourcefile from "test" to "${test}" gives exactly the same output.
The complete syntax in which SourceList is embedded has many more rules. But then I get the following results.
set(${TARGET_NAME}_DEPS
GenConfiguration_OBJ_TN_Common # accept
${COMMON_BB_PCMDEPS} # reject
COMMON_BB_PCMDEPS # accept
COMMON_BB_PCM_DEPS # reject
)
for which I want to have a solution.
What is wrong with the minimal example? Why is test or ${test} not accepted?
BTW: I am using the latest unstable. Does it make sense to install and try the stable release?
I've tried to reproduce your problem, but it seems to work here:
rascal>parse(#SourceList, "test")
SourceList: (SourceList) `test`
The unstable version is fine at the moment. In fact it's high time to release a stable version. So for now you're better off with the unstable version.
The CallFailed exception is confusing. It means that a function is called which can not be matched OR not be found. So maybe parse is not in scope by not importing ParseTree, or you have a different function called parse which does not have a type[Tree] and str as the expected parameters in scope. As long as the ParseTree module is imported, you're call to parse should be fine.
Please let me know if you have made progress. Perhaps a restart of Eclipse might clear up something as well.

How to access build folder number in TFS 2017

I typically tell TFS what folder to use via $(build.sourcesdirectory) which translates into C:\Builds\1\s .
However, I need to repack the deployment zip, so I had to add Content\C_C\Builds\myproj\1\s to my CI.
This isn't very good as the 1 can change due to dev ops work.
Is there a variable or technique I can use to replace the 1 with a variable?
I tried $(Agent.Id) with no luck...
You can use PowerShell to retrieve the number from variable $(build.sourcesdirectory) and pass the value to a new variable.
Dynamically get the number Sample:
$string = "$env:BUILD_SOURCESDIRECTORY"
#$string = "E:\andyli-v\01Agent\_work\6\s" (The length is 29, the number '6' in the string is the 27th character, So get the substring as (26,1) means get one character behind the 26th character)
$parameter = $string.Substring(26, 1)
Write-Host "BUILD_SOURCESDIRECTORY is :" $string
Write-Host "The String length is : "$string.Length
Write-Host "The number is : "$parameter
You can use $parameter directly to get the number if do actions within the same script.
Set a variable :
If you want a variable, you can set it via PS :
Write-Output ("##vso[task.setvariable variable=GetNumber;]$parameter")
You can reference there articles to set the variable:
https://roadtoalm.com/2016/08/11/set-output-variable-in-a-powershell-vsts-build-task/
http://blog.majcica.com/2016/02/19/passing-values-between-tfs-2015-build-steps/

FitNesse: Is it possible to extract information from the response of a test step, and use this value in the next test step

I am wondering that is there any possibility in FitNesse, while executing the test stages, to get a value from the response of a test stage and use this value in the next test stage.
I am using hsac-fitnesse-fixtures and SOAP web services.
For example, we have 3 test stages, and value from the response of the first stage can automatically transfer to the second stage to get the response of the second stage.
When comparing with SOAP UI we have property transfer.
Example below:
We have request XML:
!define POST_BODY_2 { {{{
<ns1:ZIP>#{zip}</ns1:ZIP>
</s11:Envelope>
}}} }
Stage 1:
|check|xPath|//weather:City/text()|#{City}|
And we get a response XML that contains the city name, as here.
Is it possible to pass this city name as a value to the second test stage?
I.e we have another post XML request !define POST_BODY_3 and to this request can we pass the value (city value) and have the next response XML.
Stage 2 test:
|check |response status|200|
If you are using SLiM as test system, you can use slim symbol
$slimSymbol is a "runtime variable" used in SLiM test system. They are defined by using $slimSymbol= symtax in the test case, and the value will only be available in the runtime. Documentation here
In your case, you are using a decision table in the first test case. So instead of having only one output column, I guess you can do
#some setup here
| send request |
| zip | City? | City? |
| 10007 | New York | $response1= |
| 94102 | San Francisco | $response2= |
And in the later test case, you can refer to the city names using $response1 and $response2. Note that there isn't {} around the variables.

What is the proper way to execute a batchfile with multiple params?

I have a batchfile which I use for managing the translation of various programs.
Now I want a delphi application to call this batchfile and pass on the parameter it needs for further processing. Unfortunately the parameters contain spaces which leads to a splitup. Is there a way to keep all parameters tied up as intended?
this is how my batchfile looks:
ECHO Scan for new ressources
%MLDIR%\Ml7Build.exe s %1%
ECHO Import glossary for new translation
%MLDIR%\MlBuild.exe i %2%
ECHO Create translated application
%MLDIR%\Ml7Build.exe b %3%
I tried to use the ShellExecute-Command from ShellApi because I found several similar questions on SO, but none of them could help me in solving my problem. My delphi code looks like this:
param1 := ExtractFileName(hMLProj);
param2 := '-f: '+MLWorkDir+'Prev_'+ExtractFileName(hMLProj)+' -settings:Auftrag_Test.importsettings-method:2 -overwri:3 -error:2 '+ExtractFileName(hMLProj)+' ';
param3 := ExtractFileName(hMLProj);
ShellExecute(0,'open',PCHAR(MLWorkDir+'__AutomatedTranslationFUBAR.bat'),PChar(param1 +param2 +param3),nil,SW_SHOWDEFAULT);
ECHO Scan for new resources
%MLDIR%\Ml7Build.exe s %~1
ECHO Import glossary for new translation
%MLDIR%\MlBuild.exe i %~2
REM is 7 ^ omitted here?
ECHO Create translated application
%MLDIR%\Ml7Build.exe b %~3
Note that %n not %n% (n=1..9) refers to the parameter n supplied to the batch. The tilde removes "any enclosing quotes."
Parameters require to be "enclosed in quotes" (and they must be double-quotes) if they contain separators such as spaces.

How to change Get-Mailbox output

I apologize in advance as I am still fairly new to powershell. I'm figuring things out as I go, but this specific issue is stumping me. Currently this is with powershell 2.0 on exchange 2007.
I am trying to add to a script that I have been writing up that shows the basic information for our exchange accounts. This is just a small tool to be introduced to our help desk to assist in a quick overview of what is going on with a user's account. I have everything working, however, I want to change what is displayed. For example, I have:
Get-Mailbox $username | ft #{label="Hidden from GAL"; expression= {$_.HiddenFromAddressListsEnabled}}, #{label="Restricted Delivery"; expression={$_.AcceptMessagesOnlyFrom}} -auto | out-string;
Which ends up returning true/false for hidden from address list, but for Accept Messages, if it is disabled, it returns "{}" (without quotes). If it is enabled, it displays the full group name (along the lines of admin.local/groupname). I only want to change {} to disabled, and instead of showing the group name, just show "enabled"
I tried an if/then statement, and then tried putting the variable "messRestrict" in the expression for accept messages above, and then the function name, but neither worked. They just returned blank values or always said "true." Here is the function:
function restricted {
$accept = Get-Mailbox $username | AcceptMessagesOnlyFrom | select -expand Priority
#if ($accept -match "\s")
#{$messRestrict="False"};
#else
#{$messRestrict="True"};
}
The output is the standard Get-Mailbox output, I just want to replace what it says under the header.
Thanks!
You can try this :
#{label="Restricted Delivery"; expression={if($_.AcceptMessagesOnlyFrom){"Enabled"}else{"Disabled"}}}
It gives :
Get-Mailbox $username | ft #{label="Hidden from GAL"; expression= {$_.HiddenFromAddressListsEnabled}}, #{label="Restricted Delivery"; expression={if($_.AcceptMessagesOnlyFrom){"Enabled"}else{"Disabled"}}} -auto | out-string;

Resources