running a powershell script on multiple servers using Jenkins - 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

Related

Is there a way to add multiple agents in the agent step(declarative pipeline)so that I can be able to run the build on the multiple agents parallelly

I'm using Jenkins (2.332.2) on a ubuntu 20.04 machine. Currently I'm using parallel step to achieve this, but the script looks a little big as I have to specify agent none in the beginning and have to mention the different agent names for every stage.

How to run jmeter script parallely on Jenkins

I want to run jmeter script parallely through jenkins.
currently i have tried BZM-concurrency thread group and Parallel controller to achive this on my local machine, which is working fine. please help me to run it through jenkins, it get finish with success but script never starts. Do i need any plugins on jenkins to achieve this?
my set is shown below, let me know is there any other way to achieve this.
You need the same plugins in Jenkins master (and all the slave if any) which are used in the test plan, the easiest is just to copy the existing JMeter installation folder to Jenkins instance(s)
Alternatively you can install the required plugins using JMeter Plugins Manager
If your Jenkins doesn't have the GUI - it is possible to install the plugins via the command-line

Jenkins skip some jobs in chain of freestyle jobs

We got a requirement to implement CICD using Jenkins.
Here, Jenkins is running in windows machine and application server running in linux machine and build activity should happen in Linux system. So, We are connecting to linux machine using Jenkins's SSH plugin and executing jobs.
I have created list of freestyle jobs to checkout code from CVS, cleanup activity, Build , stop server, start server, Run Junit, run sonar. all these jobs are chained using 'build other projects' option in post build Action section.
Here, all jobs executes in sequential manner. But, sometimes I need to execute only few jobs like stop and start server.
So, please help me how we can randomly pick jobs which need to be run before triggering build.
Thanks,
Ganesha

Distributed execution with Jenkins

I am working on a Robotic process automation where i need to automate 10 different process flows.Robot needs to run 24/7.My solution is hosted in AWS cloud and i have got 10 cloud machines to run the scripts.
I have a master Jenkins job which will retrieve the list of automated jobs to execute from a database and i have 10 different jobs configured in Jenkins server.Number of jobs that i need to run at the same time varies from time to time.It may be N different scripts or N instances of the same script with different data combinations.
Challenge i am facing is in post build action i am not able to control the list of scripts/jobs that i need to run based on the output from Jenkins master job.Is there any way to run only the job i need based on the output from a build command?
I was able to achieve it using Jenkins Flexible Publish plugin.

How to create single Jenkins project for run in multiple platforms

My Jenkins server has multiple slaves with different platforms (Windows, Linux and Mac). I need to run a job in each slave to copy a network folder to each local machine. Here are few questions I have.
Can I create a single project with Batch, bash, Mac bash script and add condition to execute.
Can I create multiple project for each platform and add condition to run depends on the platform.
Is there any use of Multi-configuration project for this situation
What is the best way to achieve this
I would look at using a configuration management tool such as Chef or Puppet, which provides a platform independent DSL to do operations such as copying files. You could then set up a multi-configuration job in Jenkins to run the same job on each of the different slaves.
The simplest way is to create a job in Jenkins that will archive the network folder each time something changes in it, and use the Copy Artifact Plugin to take it to the workspace of each slave wether it is Linux or Windows.
Simple, elegant :)

Resources