Run build of Machine A from Machine B using Jenkins - maven

I have 2 computers. Com-A, Com-B.
I have build automation functional script using selenium webdriver,Testng and maven on Com-A.
Com-A has installed everything with Jenkins but Com-B has only jenkins , Can I run build which is deployed in Com-A from Com-B? Or I will have to install all necessary software to Com-B also?

Your current setup is good enough to kick off the build remotely from Com-B to Com-A.
Please make sure the jenkins server deployed on Com-B has properly configured as Master and other nodes (ex : Com-A) as slaves.
To ensure the configurations, please follow the steps given below :
Step 1: Go to Manage Jenkins page and select Manage Nodes link
Step 2: On Manage Node page, you can see a list of nodes if already configured. Else there will be only one node named as Master by default which represents the host.
Step 3: To add new Node, give a name (ex: selenium-slave1) and select Dump Slave option to add a node as customized slave.
Step 4(a): After adding the node, configure the node as shown below.
Step 4(b): Make sure while setting the Launch Method field, Launch slave agents on Unix machines via ssh has been selected (this will communicate via ssh between master and slave nodes).
Step 4(c): configure advanced fields which are highlighted as per your settings and click save.
Step 5: Finally a new node has been added as slave and configured successfully.
Step 6(a): Now Configure a new Job to schedule it whenever it need to be run.
Step 6(b): Add a new maven job since your project has been configured using maven.
Note : Will add the job config soon.

You can make Com-A a slave machine in jenkins. Com-B will become master and mark the build to always run from Com-A node.
Refer https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines

First of all, u don't need to install all thing in COM B.
Connect with COM A with ssh(secure shell) command and than execute ur project using shell or bash script. In jenkins, u will found all build step under Build option.
i use the below command to run my project using shell script:
ssh -l user comAIpaddress(ex. 192.192.192.192) sh SciptLocationInComA.shell
this command first connect with another machine and than execute the shell script to run the project.
Run a java project using shell or bash script is quite easy..... :)

Related

Run multiple jobs in parallel in Atlassian Bamboo

I would like to run multiple jobs in parallel on the same automation server. For this I need as many agents installed as the number of parallel jobs.
When I try to install an additional remote agent the installer picks the location of the first agent that is already installed on the automation server. As a result the installation fails.
What I did was: I turned off the first agent and then I run the installer for the new remote agent.
How should I go about installing an addition remote agent?
Regards,
Archie
location of the first agent
I presume you're referring to the agent's home dir. Try overriding it per agent with a distinct location using:
-Dbamboo.home=/opt/bambooX
More info: https://confluence.atlassian.com/bamboo/additional-remote-agent-options-436044733.html

How to configure docker swarm using jenkins?

I have got an assignment. The assignment is "Write a shell script to install and configure docker swarm(one master/leader and one node) and automate the process using Jenkins." I am new to this technology and finding it difficult to proceed. Can anyone help me in explaining step-by-step process of how to proceed?
#Rajnish Kumar Singh, Have you tried to check resources online? I understand you are very new to this technology, but googling some key words like
what is docker swarm
what is jenkins , etc would definitely helps
Having said that, Basically you need to do below set of steps to complete your assignment
Pre-requisites
2 or more - Ubuntu 20.04 Server
(You can use any linux distros like ubuntu, Redhat etc, But make sure your install and execute commands change accordingly.
Here we need two nodes mainly to configure the master and worker node cluster)
Eg :
manager --- 132.92.41.4
worker --- 132.92.41.5
You can create these nodes in any of public cloud providers like AWS EC2 instances or GCP VMs etc
Next, You need to do below set of steps
Configure Hosts
Install Docker-ce
Docker Swarm Initialization
You can refer this article for more info https://www.howtoforge.com/tutorial/ubuntu-docker-swarm-cluster/
This completes first part of your assignment.
Next, You can create one small shell script and include all those install and configuration commands in that script. Basically shell script is collection of set of linux commands. Instead of running each commands separately , you will run script alone and all set up will be done for you.
You can create small script using touch command
touch docker-swarm-install.sh
Specify proper privileges to script to make it executable
chmod +x docker-swarm-install.sh
Next include all your install + configure commands, which you have used earlier to do docker swarm set up in scripts (You can refer above shared link)
Now, when your script is ready, you can configure this script in jenkins job and whenever jenkins job is run, script will get execute and docker swarm cluster will be created
You need a jenkins server. Jenkins is open source software, you can install it in any of public cloud instance (Aws EC2)
Reference : https://devopsarticle.com/how-to-install-jenkins-on-aws-ec2-ubuntu-20-04/
Next once installation is completed. You need to configure job in jenkins
Reference : https://www.toolsqa.com/jenkins/jenkins-build-jobs/
Add your 'docker-swarm-install.sh' as build step in created job
Reference : https://faun.pub/jenkins-jobs-hands-on-for-the-different-use-cases-devops-b153efb483c7
If all set up is successful and now when you run your jenkins job, your docker swarm cluster must be get created.

Jenkins through docker: How to configure own host as agent for jenkins?

I'm using Jenkins with pipelines on a mac-mini. All builds are working fine with docker agents (backend, frontend, android app, etc)
The only thing I haven't been able to achieve is to use my own mac-mini as build-agent/slave for the IOS app (I need to build on OSX). Jenkins itself runs through docker as well, so I would need to connect to the host (the OS of the mac-mini) and use that as an agent...
I know one option would be to install jenkins instead of using docker, but I would prefer to keep Jenkins running in a docker container.
Does someone has experience with this or knows any good documentation on how to set this up?
Go to Manage Jenkins > Manage Nodes > New Node.
Configure a node.
Go to the list of nodes.
Select your newly configured node. It should be offline at this moment.
Run the java command displayed on the interface on your host machine.
Your Host machine is now a slave.

Cannot install jenkins slave on a windows machine

I am a very newbie to Jenkins ,
I am trying to Lunch a slave via Java Web Start, and when i try to install the Jenkins slave knowing that the master address is as follow http://masterdomain.com i see that the slave tries to connect to http://masterdomain.com:54999 , any ideas why this happens
Jenkins uses a special port for connections between the slave and the master. By default the port number is variable, but if you have a firewall between the master and the slave you can fix the port number via the URL <your Jenkins master URL>/configureSecurity/
Hey to answer your question from the comments above, the MASTER URL for jenkins is configured in the Manage Jenkins --> Configure System --> Jenkins Location
The Java Web start tries to get the URL from this location setting and uses it to setup the JNLP Agent on the slave.
Hope this helps.

How to force Jenkins to launch webpage/ cmd prompt in client (user's) machine?

The job that I was trying to create in Jenkins would require launching a webpage on the user’s browser once the build is successful (Jenkins is installed on a remote server). For doing this I put the following line in the " Build - Execute Windows batch command" section of the job’s Configure page:
START http://google.com
While the build was successful, it did not launch the page. I have a hunch, this line will try to launch the webpage in the remote Jenkins server (it did not launch anything in the slave node though). My question is, how do I force the Jenkins job to launch the webpage in the user’s default browser?
I tried launching client's cmd.exe - this did not work either.
Jenkins master, slave, user's client - everything is on Windows. Jenkins version 1.46.
Thanks!
By "launch in client's machine" you mean the user that is accessing the web interface of Jenkins? No, this won't happen. It can be quite a security risk too.
You can do what you are asking either on the master or the slave. Jenkins does not directly execute anything that is not on master/slave. It is possible to spawn a slave on user's machine, and when the job is run, it will execute the command on the slave.
Or if the user provides his/her computer IP address as a parameter to the job, you could use PsExec to connect to user's computer to execute a command.

Resources