Run Jenkins job from node in different pools - jenkins

I would like to create a single Jenkins job that runs a command for Linux and for Windows, where it has a pool of Linux nodes and a pool of Windows nodes to use.
As a simple silly example suppose
I want the helloWindows.bat command executed on a single windows node
I want the helloLinux.sh command executed on a single Linux node
I have a pool of Windows agents under the label Win to choose from
I have a pool of Linux agents under the label Lin to choose from
How could I configure this using a Freestyle, Matrix or MultiConfiguration job?
I know how to do logic that will run a Windows batch command on a Windows machine and run a Linux shell command on a Linux machine. However, I don't understand how I can have one windows run be pulled from the Windows pool and one Linux run from the Linux pool.

I kept playing with it and I think I figured it out. I'm still testing but so far it looks like it's correct.
Multiple Windows agents configured and using label Win
Multiple Linux agents configured and using label Lin
Create a Multi-configureation project
Under Configuration matrix
Add an Axis named Agents
Name it label
Expand the Node/Labels/Labels option
Select Win and Lin
Under Build
Use Conditional steps to determine Windows vs. Linux
Use Execute shell for Linux
Use Execute Windows batch command for Windows

Related

Setup & Execution of Jmeter Distributed Test run from Jenkins

i'm looking for some assistance in execution of Jmeter distributed test runs using Jenkins hosted on Windows platform.
I need to know how to
Start Jmeter master/slave agents (jmeter-server.bat) from Jenkins machine.
how to stop the above process once the test run completes.
A hint: if you don't "stop the above process once the test run completes" you won't have to "start" them.
If you want to control everything from Jenkins you need to install Jenkins agent process on each machine you intend to use as JMeter slave, see Step by step guide to set up master and agent machines on Windows Jenkins wiki page for more details.
Once done you can create a job which will start JMeter processes using simple "Execute windows batch command" step on the agent machines
With regards to your point 2 - it's sufficient to set server.exitaftertest JMeter property to true on slave machines in any convenient way, i.e. by adding -J command-line argument like:
jmeter-server.bat -Jserver.exitaftertest=true
For any Distributed Load Run via Jmeter, the pre-requisite is to get the Jmeter-server.bat running to support and enable master-slave communications by Jmeter between Load agents. Initially i had a struggle how to get this executed as first step in Jenkins and then followed execution of Jmeter commands for load test using Remote distributed run. Hence instead of running the pre-requisite condition of running Jmeter-server.bat from jenkins i made it as a Windows service (as load agents are windows machines) which is running all time and whenever Load test starts from Jenkins, the Jmeter-server running in background which will allow distributed run to go.

Jenkins: Execute a job where the project/workspace is located on other machine (LAN Network)

Having a PC for developing working with STS/Eclipse and Jenkins both working in the same machine and same time.
Now for pre-production testings is mandatory use servers running together such as ActiveMQ, RabbitMQ, MySQL, PostgreSQL
Due this the PC goes slower, even worst if SonarQube and JMeter are running.
The solution needed is have in the same LAN network two machines.
Machine A: with IDE just running with some servers running too, MySQL and ActiveMQ
Machine B: running Jenkins (and optionally SonarQube and JMeter)
Thus the tools dedicated for:
Continuous Integration (Jenkins)
Continuous Inspection (SonarQube)
Measure performance (JMeter)
are running in a dedicated machine, in this case B.
Currently when all is based in one machine. The following is used:
Thus Jenkins is able to work directly with the workspace
Therefore how through Jenkins or with a special plugin we can refer to execute a job, to execute a set of #Test, where the project (workspace) is located in other PC?
The project itself about all its #Test methods should be not aware that is being executed remotely from Jenkins
Should only exists one Jenkins server working over the network.
What is the best approach to accomplish this goal?

Jenkins Master on Linux to trigger PowerShell script on windows slave

I have a Linux server where I have installed Jenkins and I have a windows slave server too. Just wanted to know is it possible to run powershell task from windows slave as we have Jenkins installed on Linux server? Or do I need to make a windows master to run all these powershell tasks?
This is possible. Make sure that you select the appropriate slave (using label expressions) to execute the job.

running a powershell script on multiple servers using Jenkins

I have a situation where I need to run a clean up script written in powershell on Multiple servers , say around 100 windows servers.
How do I accomplish this ?. Doing thru SSH would be cumbersome I believe . I am looking for a better way to configure the Jenkins job to get this task done.
Regards
Raj
First Solution
Install a Jenkins agent on all your Windows machines
Affect the same label on all these Windows nodes
Next, you have to install the Matrix Project plugin and create a multi-configuration job.
You have to configure the matrix to run your job on the specific label:
This job will execute your Powershell maintenance script on all the Windows nodes.
Here is a screen copy of a similar maintenance job I'm running on my CentOS nodes:
Second solution (not tested)
The second solution (using OpenSSL) is to execute your Powershell script remotely:
https://hodgkins.io/automating-with-jenkins-and-powershell-on-windows-part-2

How to use jenkins to build client-server projects

The application I am looking to build is a distributed system with a server (and several other components) running on a linux machine and a client on the windows machine. At every commit I need to build both the components (linux first and windows next) and run some sanity tests
I installed Jenkins slave on the windows machine, but can't find a plugin which will let me link each build-step in a project to a different machine.
i.e I need to say
Run build-step A on machine M1
Run build-step B on machine M2
Run build-step C on machine M1
Think I can create three different projects for each of these jobs and create a fourth project and have 3 jobs triggering the 3 projects in the required order ("Trigger/call builds on other projects). Is this the only way to do it or is there a plug-in I can use to choose a different machine for each build-step in a project.
Once you have your slaves set up, you can tag them with labels like "windows", "linux", etc. Then you can restrict your jobs to only run on nodes with certain labels.
See Jenkins: The Definitive Guide for more details.

Resources