Can you pass agent-specific parameters to a wandb sweep? - wandb

I would like to be able to pass a particular parameter with a different value on each agent in my wandb sweep.

Related

How to convert MultiSelect values from Active Choice Parameter in Jenkins into an array or list?

I have parameterized job with 'list' MultiSelect parameter in Jenkins:
I want to build this job only with selected values:
And for this purpose, I want to pass this selected values to pipeline script in this job and convert them into an array or list.
The following code doesn't work properly:
Please, help me to write the proper code in groovy to convert selected values to array or list.
Thanks,
Anastasiia
Assuming parameter name "list" and property setting described in question, below pipeline code worked for me.
String[] arr= "${params.list}".split(',');
for (x in arr) {
echo "$x \n"
}
This will print each selected values on new line.

Apache Beam/Dataflow: Passing in attributes between Transforms

Is there a way to pass meta data/attributes between PTransforms? This information is not part of a element, but should be accessible when processing elements. I have a constraint that this information cannot be passed in as a constructor argument.
Why can't it be passed in as a constructor argument?
Is the value unknown until you get to a particular Transform? If so, the you could retrieve it as an additional output, and then input it everywhere it is needed as a side-input by using pvalue.
https://beam.apache.org/documentation/programming-guide/#additional-outputs
https://beam.apache.org/documentation/programming-guide/#side-inputs
https://beam.apache.org/releases/pydoc/2.8.0/apache_beam.pvalue.html#apache_beam.pvalue.AsSingleton

currentBuild() in jenkins

I have a DSL FreeStyleJob in jenkins. Let's say job/project named A is calling another job/project B as a post-build actions. I am making use of downstreamParameterized and passing currentBuild() paramaters as below
downstreamParameterized {
trigger(B) {
condition('SUCCESS')
parameters {
currentBuild()
}
}
}
And I know job/project B to be parameterized (Also DSL job). But how do I accept currentBuild() as a parameter in B. But I don't see any option related to it. Can anyone suggest?
See this pic for parameter options
I have already tried with predefined properties in job/project A and string parameters in job/project B and it works fine. But I don't want to follow this as there are many different type parameters in current build parameters.
I can't take file parameter options as both job workspace are different.
Solution is straight forward if the parameters are same for both the jobs. All you need to do is to declare the same set of parameters in JOB B as in JOB A. Jenkins will take care of passing the parameters to the downstream job.
As long as you have the same set of parameters in both the jobs it should work.
Reference :
Job 1 :
Job 2 :
Parameterized trigger in JOB 1
Thanks

Dynamically update instance variable

I would like to make an API call dynamically. API (Get) result must vary dynamically based on the query string passed.
I have hard coded the API URL without any query string, and supplied the API URL as an instance variable:
#apiRequest = HTTParty.get("http://localhost:1880/api/devices")
#parseApiRequest = JSON.parse(#apiRequest.body)
I want #apiRequest to change dynamically based on user input from a form (I had already developed a form that gets inputs from user's).
Is it possible to change the value of an instance variable dynamically? User's input value must be passed onto that controller as a query string.
Sample image that gets user input:
Getting User Input
The instance variable must be updated dynamically as,
#apiRequest = HTTParty.get("http://localhost:1880/api/devices?device_id=123456")
Kindly suggest.
Simply interpolate the dynamic data into the api request parameter string:
extraParamsOrPath = "assemble this from form inputs"
urlPrefix = "http://localhost:1880/"
#apiRequest = HTTParty.get("#{urlPrefix}/#{extraParamsOrPath}")
And make sure the user input is sanitized ;)

Not able to read parameters from properties file in jenkins

Here is what I am trying to achieve. - I have two 'Choice Parameters' in my Jenkins job. The values of the first Choice Parameter are hard coded. The second choice list should be populated based on the first choice list selection. I have one properties file saved in Jenkins, which has key-value pairs. The values in first choice list and the Keys in the file are same. On selecting a value in first choice list i want a code to read the properties file and populate the second choice parameter with the values from file corresponding to that key.
For second choice list i am trying with 'Active Choice Reactive Parameter' , Referenced parameters= first_choice and below groovy script. But this is not returning any values. Please help!
def firstChoice = [first_choice]
Properties props = new Properties()
def stream = new FileInputStream('C:/Jenkins/books.properties')
try{
props.load(stream)
}
catch (Exception ex){
println "Exception"
}
finally {
stream.close()
}
def values = props.getProperty(firstChoice).split(",")
return values
Are the parameters defined in your job? if you're trying to inject parameters that are not defined in the job you need to either define them or add exception in Jenkins when you're loading the master service.
More reading:
https://wiki.jenkins-ci.org/display/JENKINS/Plugins+affected+by+fix+for+SECURITY-170
Follow this answer and use active choices parameter. This will help you achieve what you want to
https://stackoverflow.com/a/73742809/4781673

Resources