Jenkins server: centos6.8
Client: windows server2012 windows10
Tool: cwRsync
Note: Copy the jenkins working directory to the website directory, no server is required.
1. Install jenkins
slightly.
2. Configure and install the slave side
Plugin used: Copy Data To Workspace Plugin
https://wiki.jenkins.io/display/JENKINS/Copy+Data+To+Workspace+Plugin
2.1 Configure windows node
1. Main interface->[System Management]->[Manage Nodes]->[New Nodes] to add nodes:
2. Enter the node name and select [Permanent Agent]. If a slave has been added, the [Copy existing node] operation will appear
3. Configure Node Details
The following aspects need to be paid attention to in the configuration here
[# of executors]: It is recommended not to exceed the number of CPU cores, and generally do not write too large.
[Remote working directory]: When the master copies the code in the code base to the slave, the temporary directory stored, such as the slave's daemon service, will also be placed in this directory. One job is one folder.
[Usage]: Select [ Only allow running jobs bound to this machine ], in this mode, Jenkins will only build jobs that are assigned to this machine. This allows a node to be reserved exclusively for a certain type of Job. For example, to execute tests continuously on Jenkins, you can set the number of executors to 1, then there will only be one build at a time, one executor will not block other builds, and other builds will run on another node.
[Startup method]: Select [ Launch agent via Java Web Start ] to start it as a windows service, which is the best configuration. Note: The 2.x version does not have this option by default and needs to be enabled separately.
4. Configure the slave side and add it to the windows service
After clicking save, this list will exist in the node list. The default is the disconnected state.
Clicking to enter the details page will prompt the installation method of the slave side, here is the method of downloading the file.
【Launch】:Browser download file method
[Run from agent command line]: run from the remote agent command line
Note: This is a java service, and each slave must have jdk installed before it can run.
The content of the downloaded file is as follows:
<jnlp codebase="http://10.0.0.11:8080/jenkins/computer/test/" spec="1.0+"> <information> <title>Agent for test</title> <vendor>Jenkins project</vendor> <homepage href="https://jenkins-ci.org/"/> </information> <security> <all-permissions/> </security> <resources><j2se version="1.8+"/> <jar href="http://10.0.0.11:8080/jenkins/jnlpJars/remoting.jar"/> </resources> <application-desc main-class="hudson.remoting.jnlp.Main"> <argument>c55442e04b03c2fc721ec718b70646c234b4c79a678ff10ccadc59541dbb843</argument> <argument>test1</argument> <argument>-workDir</argument> <argument>d:\jenkins</argument> <argument>-internalDir</argument> <argument>remoting</argument> <argument>-url</argument> <argument>http://10.0.0.11:8080/jenkins/</argument> </application-desc></jnlp>
Note: The content of each slave is different. Multiple slaves need to download or modify this content multiple times
The reason for the following error in the installation is that there is no permission, and it is run as an administrator.
There is no menu to run as administrator by right-clicking this file, open [Task Manager] -> [Run] -> [Run as administrator]
Uninstall system services:
sc delete jenkinsslave-c__jenkins
After the installation is complete, the remote directory set by the slave will generate the following files
Return to the node list of the master and find that it is already connected here.
4. New construction
Choose the Free Build method.
[Restrict where this project can be run]: Restrict the node running this project to the windows that the label filled in when node was just set.
This option appears after downloading and installing the plugin. In fact, it is useless to fill in the path.
Here choose to execute windows command
Note: The following issues exist here.
1. If the file does not exist in the code base, or the file is deleted after the update, then use xcopy to delete the file in the code base, and the file in the slave node folder still exists. Could not clear. Solution Use rsync –delete or execute the script file to judge.
2. If files that do not exist in the code base need to exist in the slave node, use rsync to delete the files that need to exist.
3. There are no environment variables here. The full path is required to execute the command, and Chinese and spaces cannot exist.
C:\tools\cwRsync\bin\rsync -avz ./ /cygdrive/c/test1/ --delete --exclude=.svn xcopy /y /e /r ./ /cygdrive/c/test1/
Test Results
View web directory contents
build code