Jenkins parameter value not displaying - html

Goal: Declare a conditional multi-line string parameter
Approach:
I have defined two jenkins parameters.
Active choices parameter
Active choices reactive reference parameter(Choice type: Formatted HTML)
In the pipeline, I am just looping over both parameters and printing them
pipeline {
agent any
stages {
stage('print each paramter') {
steps {
script{
params.each {param ->
println "${param.key} -> ${param.getValue()} "
}
}
}
}
}
}
and this is the output
Second parameter is not printed. I have also tried echoing it with
echo ${inventory}
echo ${param.inventory}
echo ${params.inventory}
but it's not working.
Any suggestions how I can declare a conditional multi-line string parameter?

Active choice reactive parameters rendered as HTML can be passed to build only if is hidden and formatted as input. See Behavior and Rendering Summary in the official documentation.
The HTML parameters are only for visualization purposes, not for returning a user input value. For build parameters, use active choice and active choice reactive parameters.

Related

API Jmeter create a reusable request depends on the selection of the user

Does anyone know how simulate scenario below and write on a reusable format? Your response is highly appreciated. Thanks!
Example I have this userdefine variable name "userInput" if user tries to enter these following metrics it should generate the corresponding request as well. Note variable name may varries from time to time depends on user selection.
Scenario 1 - network,cpu,process
{
"networkMetric": "network.json",
"cpuMetric": "cpu_json",
"processMetric": "process_json"
}
Scenario 2 - cpu,process
{
"cpuMetric": "cpu_json",
"processMetric": "process_json"
}
Scenario 3 -network,cpu
{
"networkMetric": "network.json",
"cpuMetric": "cpu_json"
}
Scenario 4 - process
{
"processMetric": "process_json"
}
You can generate the "request" using a suitable JSR223 Test Element (i.e. JSR223 PreProcessor) and the following code:
def payload = [:]
vars.get('userInput').split(',').each { metric ->
payload.put(metric + 'Metric', metric + '_json')
}
vars.put('request', new groovy.json.JsonBuilder(payload).toPrettyString())
you will be able to refer the generated request body as ${request} where required and the body will depend on the ${userInput} variable value.
More information:
Apache Groovy - Parsing and producing JSON
Apache Groovy: What Is Groovy Used For?

Html Data Attribute Not Properly Translating To "success" Portion of "jquery.get()" in HtmlHelper

I'm trying to create an HtmlHelper for jstree nodes. Part of my objective is to encapsulate the "select_node" logic into a re-usable format. For our purposes, we can expect to use a jquery "GET" which will call into an MVC controller method. That URL needs to be dynamic and is passed in via an html custom data attribute. The resultant behavior upon success also needs to be dynamic and is also passed in via the same means. My problem is that, despite the passed in URL being interpreted and called properly (the controller method is hit), I cannot get the "success" portion to work properly. Below are code examples with corresponding comments. The non-working scenario (the last commented attempt with "data.node.li_attr.success") would be the ideal as we would need to pass in multiple lines.
writer.WriteLine("</ul>");
writer.WriteLine("</div>");
writer.WriteLine($"<script>");
writer.WriteLine($"$({treeParamModel.TreeName}).jstree({{"); // base tree definition
// "core" config standard to every jstree
writer.WriteLine("'core':{");
writer.WriteLine($"'multiple':{treeParamModel.IsMultiSelectAllowed.ToString().ToLower()}");
writer.WriteLine("},");
// "types" plugin
writer.WriteLine("'types':{");
writer.WriteLine("'default':{");
writer.WriteLine($"'icon':'{treeParamModel.IconPath}'");
writer.WriteLine("}");
writer.WriteLine("},");
writer.WriteLine("'plugins' : ['types']"); // define which plugins to bring in
writer.WriteLine("})");
writer.WriteLine($".on('select_node.jstree', function (e, data) {{");
writer.WriteLine("$.get({url: data.node.li_attr.get_url,");
writer.WriteLine("success: function (result) { alert(data.node.li_attr.success)}"); // works (correctly displays variable content.)
//writer.WriteLine("success: function (result) { $(data.node.li_attr.success)}"); // WHY? "Uncaught Error: Syntax error, unrecognized expression: alert('hello')"
writer.WriteLine("});");
writer.WriteLine("});");
writer.WriteLine("</script>");
The MVC view passes in the following:
#{
var treeName = "tree";
var success = "alert('hello');";
}
Update
My colleague and I have found that we can ALMOST achieve our desired result by using the "eval()" function.
writer.WriteLine("success: function (result) { eval(data.node.li_attr.success)}");
works as expected with the exception that it stops evaluating content after the first space.

Pass multiple files to AutodeskForge Design Automation API

If i use just 1 file it works perfectly, but with more than 1 it fails
This is my request
{
"Arguments":{
"InputArguments":[
{
"Resource":"https://s3url.com",
"Name":"HostDwg1-050A-014"
},
{
"Resource":"https://s3url.com",
"Name":"HostDwg1-050A-015"
}
],
"OutputArguments":[
{
"Name":"Result1-050A-014",
"HttpVerb":"PUT",
"Resource":"https:://s3url.com",
"StorageProvider":"Generic"
},
{
"Name":"Result1-050A-015",
"HttpVerb":"PUT",
"Resource":"https://s3url.com",
"StorageProvider":"Generic"
}
]
},
"ActivityId":"PlotToPDF",
"Id":""
}
This is the error i get
The number of Arguments is bigger than the number of Parameters.
Parameter name: Count
How have to be done the request to convert more than one file, without doing a request for each file? thanks
The PlotToPDF activity declares exactly one input parameter and exactly one output parameter. An activity is like a function in a programming language: you can only provide as many arguments as there are parameters. So...
If you want to have a workitem that has more than one input/output argument then you should define an new custom activity that has more than one input/output parameters.
If you want plot multiple files then you should simply submit multiple workitems.

Update json in logic apps

I want to parse through a json and update specific nodes in json result according to the following code snippet written in power shell:
foreach($val in $getresult.elements.values)
{
if($val.Name -eq "Config")
{
$val.items.Service=$ServiceValue
}
if($val.Name -eq "Analysis")
{
$val.items.ID=$IDValue
$val.items.Name=$NameValue
}
if($val.Name -eq "Report")
{
$val.items.to=$ToValue
}
}
The final $getresult elements/nodes should be updated with $ServiceValue, $NameValue and $ToValue. How do I achieve it in logic apps?
We recently introduced new workflow functions #setProperty, in combination with condition action you will be able to set the properties inside. Or, use #addProperty if such name doesn't exist.
https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

Zend Jquery Autocomplete populate from Database

Hi I am trying to implement a autocomplete field using Zend Jquery. I followed a tutorial to grab the data from an array and I have extended the code to access the data from my mysql table.
IndexController.php
$this->view->autocompleteElement = new ZendX_JQuery_Form_Element_AutoComplete('ac');
$this->view->autocompleteElement->setLabel('Autocomplete');
$this->view->autocompleteElement->setJQueryParam('source', '/index/city');
This calls the cityAction()
public function cityAction()
{
$results = Application_Model_City::search($this->_getParam('term'));
$this->_helper->json(array_values($results));
}
I then call the Model City
public static function search($term)
{
$region = new Application_Model_DbTable_Regions();
$results = $region->getRegion($term);
return $results;
}
And finally the Regions db model
public function getRegion($term)
{
$select = $this->select()->from($this,'City')
->where('City LIKE ? ',$term.'%');
return $this->fetchAll($select)->toArray();
}
Now when I go the autocomplete field it shows the results but as UNDEFINED , I think its something to do the way I am send the data back to the json helper.
I used firebug and I can see the data is been pulled in the following format.
[{"City":"London"},{"City":"Londonderry"},{"City":"Longfield"},{"City":"Longhope"},{"City":"Longniddry"}]
I think this format is incorrect, please any body dealt with this before?
Cheers
J
The ZendX_JQuery_Form_Element_AutoComplete element is a proxy to the AutoComplete View Helper, which is a proxy to the jQuery UI Autocomplete widget.
If you read the overview on the jQuery UI Autocomplete page, you will note:
The local data can be a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both. The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.
When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data. It can be on the same host or on a different one (must provide JSONP). The request parameter "term" gets added to that URL. The data itself can be in the same format as the local data described above.
So, the JSON you are returning to the autocomplete should be structured more like:
[{"label":"London","value":"London"},{"label":"Londonderry","value":"Londonderry"},{"label":"Longfield","value":"Longfield"}]
Good luck!
Fixed the problem afters hours of pain!
I modified the below code where it accesses the data
public function getRegion($term)
{
$select = $this->select()->from($this,'City')
->where('City LIKE ? ',$term.'%');
return $this->fetchAll($select)->toArray();
}
I added a line of SQL City AS Value
public function getRegion($term)
{
$select = $this->select()->from($this,'City AS value')
->where('City LIKE ? ',$term.'%');
return $this->fetchAll($select)->toArray();
}
This seems to have worked!
Cheers
J