Jenkins Quick Start - Part 6 - Launching Jobs on the Slave Node

2018年04月27日


MyBuilds (TestBuilds)
New Item
Enter an item name: MySlaveBuild
Freestyle project

选中“Restrict where this project can be run” checkbox
Label Expression:centos-slave1

Build
Add build step
Execute shell:

sudo cat /etc/hostname


------删除线开始------
Master node
[jenkins@iz2zea8vkymp8ikspmnjdhz ~]$ ssh-keygen

[jenkins@iz2zea8vkymp8ikspmnjdhz ~]$ ssh-copy-id jenkins@10.0.0.x 

SSH到Jenkins Slave node
[jenkins@iz2zea8vkymp8ikspmnjdhz ~]$ ssh 10.0.0.x

Manage Jenkins
Configure System
SSH remote hosts
Add

Hostname: 10.168.0.136
Port: 22
Credentials: jenkins(配置了key的那个)
Kind:SSH Username with private key
Username: jenkins
Private Key, From a file on Jenkins master, File: /var/lib/jenkins/.ssh/id_rsa
------删除线结束------


MyBuilds (TestBuilds)
New Item
Enter an item name: MyTestRemoteBuild
Freestyle project

选中“Restrict where this project can be run” checkbox
Label Expression: centos-slave1

Build
Add build step
选择“Execute shell script on remote host using ssh”
SSH site: jenkins@10.0.0.x:22
Command:
sudo cat /etc/hostname

Build Now



Category: Jenkins Tags: public

Upvote


Downvote