currentBuild() in jenkins - 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

Related

how agent pass data to task router?

I have an issue.
here is my flow:
agentA-->taskRouter-->agentB.
I know how to pass data(some additional customer info) from taskRouter to agentB(by attribute), but I don't know how agentA pass data to my taskrouter.(or how taskrouter receive the data)
Twilio developer evangelist here.
To pass data to other agents on a task through Flex, you can add further attributes to your task from within the Flex interface.
You would need to build a Flex plugin that allows you to add that data. I have an example Flex plugin that adds a text input to the task panel and allows agents to use it to set the customer name in the task attributes.
Once you have access to the task object, you can update the attributes with the function:
task.setAttributes(newAttributes);
setAttributes does overwrite existing attributes, so ensure you don't lose all the existing attributes like so:
const newAttributes = { ...task.attributes, name: this.state.name };
task.setAttributes(newAttributes);
This will update the attributes on the task that another agent will then see when they are assigned the task.

Azure data factory - query pipeline by data annotations

Is there a way to programmatically query (using .net SDK) list of running pipelines by data annotations?
I can set data annotation when I run pipeline as explained here, but not sure how to query pipelines or filter pipelines using the same?
According to the API documentation, query pipelines by annotation is not supported. Filter parameter support following:
Gets or sets parameter name to be used for filter. The allowed
operands to query pipeline runs are PipelineName, RunStart, RunEnd and
Status; to query activity runs are ActivityName, ActivityRunStart,
ActivityRunEnd, ActivityType and Status, and to query trigger runs are
TriggerName, TriggerRunTimestamp and Status. Possible values include:
'PipelineName', 'Status', 'RunStart', 'RunEnd', 'ActivityName',
'ActivityRunStart', 'ActivityRunEnd', 'ActivityType', 'TriggerName',
'TriggerRunTimestamp', 'RunGroupId', 'LatestOnly'

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.

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

Workflows with Dynamic nodes

I'm trying to configure a Jenkins's Workflow (Trough workflow-plugin) that can work with dynamic node names in an environment in which slaves are managed automatically.
Unfortunately it turns out that node() does not support regex, nor the common wildcard *:
node('node-*') {
}
There is any way to make node() work with dynamic slave names?
OK This is sort of a RTFM situation:
https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md
The parameter may be a slave name, or a single label, or even a label
expression such as:
node('unix && 64bit') {
// as before }
So I can simply use a label to identify nodes.

Resources