in Education by
In deploy scenario I need to create and run Jenkins task on the list of hosts, i.e. create something like a parametrized task (where ip address is a parameter) or a task on Multijob Plugin with HOST axis, but run by only 2 ones in parallel over multiple hosts. One of the options could be to run ansible with the list of hosts, but I'd like to see a status per each host separately and relaunch a Jenkins job if needed. The main option is to use Job DSL Plugin or Pipeline Plugin, but here I need help to understand what classes/methods of dsl groovy code should be used to achieve this. Can anyone help with it? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Let's start solving this by assuming that we have configured the hosts to Jenkins master as Jenkins slaves, and also make sure that hosts are provided in the pipeline job parameter. Make HOSTS as a separated list. Go through the code def hosts_pairs = HOSTS.split().collate(2) for (pair in host_pairs) { def branches = [:] for (h in pair) { def host = h // new variable for every iteration; it will be mutated branches[host] = { stage(host) { node(host) { // here we mention the actual job,e.g. sh "echo hello world" } } } } parallel branches } The above code will help you to understand what are the classes/methods in the dsl-groovy code.

Related questions

0 votes
    I am successfully able to connect to a remote machine using SSH but when I am launching the agent from Jenkins ... overcome this issue? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am successfully able to connect to a remote machine using SSH but when I am launching the agent from Jenkins ... overcome this issue? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I am trying to do a poc of Jenkins pipeline as code. I am using the Github organization folder plugin to ... descriptions for the jobs Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    In Jenkins, is there a way to restrict the user to view only certain jobs? Only through "Project-based ... allows job restriction? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    Can someone help me to differentiate between DevOps and Docker? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I have a Jenkins project that does a gradle build and uploads build artifacts to a Nexus maven hosted ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    If I have to build an infrastructure stack in the cloud using a tool like Ansible. Is it necessary to have the ... the best to use? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I'm trying to configure my Jenkinsfile to run in one which already have access to my git repository via ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
0 votes
    I am trying to start a local Kubernetes cluster using minikube start and getting the following error. Starting local ... this slow? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Do I need to use separate Docker containers for my complex web application or I can put all required services in ... in one container? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I want to migrate my webapp from Amazon EC2 to ECS. I ECS I have to allocate memory and vCPU for the ... needed for the process? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    Can anyone suggest me the best institute in Hyderabad for DevOps training? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me which certification is best for DevOps? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me what are tools in DevOps for testing? Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    I am setting up a common standalone-full.xml file for all server environments, and therefore need to have ... is greatly appreciated. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
...