Run build of Machine A from Machine B using Jenkin

2019-02-09 03:46发布

问题:

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?

回答1:

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.



回答2:

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



回答3:

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..... :)