Published by jenkins build common website (jenkins + nginx + svn)

This lab introduces:
nginx: Web site
svn: Code repository
jenkins: Automated operation and maintenance tool

Developers by submitting code to svn, operation and maintenance personnel automatically published to the directory by nginx configuration jenkins.

Experimental environment:
192.168.0.188 Jenkins
192.168.0.189 nginx
192.168.0.19 svn
Jenkins, nginx, svn environment have been ready, not to build here again

Step:
1.Jenkins ssh installed plug-ins, and configure the remote server
2. Establish project (job) to configure Jenkins
3. upload code svn
4. documents released by Jenkins
5. Review Test Results

1.Jenkins install ssh plugin and configure the remote server
in system management Jenkins - Plugin Manager
Published by jenkins build common website (jenkins + nginx + svn)
select the plug-publish over ssh plugin and install, have installed is ignored

Configuration management system began after installation - System configuration

Turn to the last surface, then add options to find the SSH Servers
Published by jenkins build common website (jenkins + nginx + svn)

Testing can be connected to save it

释义:
SSH Server配置为Publish Over SSH中运程机的配置,分“基本设置”和“高级设置”两部分。“基本设置”主要是运程机IP、SSHusername、SSHport、连接超时时间等。“高级设置”和大部分“全局设置”中的选项相同。
Name:建立这台机器的名称
Hostname:远程机器的地址,最好是ip地址
Username:用户名
Remote Directory:远程目录
Use password authentication, or use a different key:使用密码连接
高级设置
高级设置里能够设置SSHport、重试时间以及又一次设置“全局设置”中的选项

全局配置:
每一项都能够被SSH Server的设置所覆盖,这种设计有一个优点。在server环境比較规范的情况下,能够省去每个SSH Server分别配置的繁琐步骤。
參数说明
Passphrase:SSH的password
使用username/password登录时为username的password。使用私钥登录时为私钥的password。
Path to key:SSH私钥的文件路径
私钥文件的路径,能够是绝对路径。也能够是相对$JENKINS_HOME的相对路径
Key:私钥
私钥导出后的文本内容

扩展例子:如果不使用密码而使用秘钥远程连接该怎么做呢1.jenkins所在服务器生成公私钥对2.将公钥(idrsa.pub)传到要远程的机器上或者将公钥内容输入到远程机器authorizedkeys文件中(/root/.ssh/authorizedkeys)chmod 600 /root/.ssh/authorizedkeys3.jenkins设置私钥所在路径文件,在输入生成公私钥的密码即可(Passphrase/Password字段需要输入公私钥密码)(Path to key字段输入jenkins所在服务器的私钥文件所在路径)

假设“Key”和“Path to key”都设置,则“Key”的优先级较高,私钥的password是“Passphrase”中设置的内容。
Disable exec:禁止在目标机上运行命令
勾选后将会忽略在Job配置中“Exec command”选项中设置的命令。Jenkins的说明文档中的“The Disable exec in the advanced settings for individual configurations will be ignored.”没有全然理解。从实际效果来看,仅仅要“Disable exec”被勾选后,无论SSH Server中是否勾选“Disable exec”。Job中设置的命令都将补忽略。

2.建立job任务
点击新建任务

输入名称,并选择自由风格项目然后确定

源码管理选择svn

其中
Repository URL:项目的svn地址
Credentials:凭证
点击添加,添加相应用户名即可

选择构建后操作,选择send build artifacts over SSH
Published by jenkins build common website (jenkins + nginx + svn)
Published by jenkins build common website (jenkins + nginx + svn)

Parameters:
the Name
"System Management> System Settings" to set the SSH Sverver list of names.
Source files
are copied to the file on the machine fortune. Workspace relative path, and also supports the expression, such as the figure above "* / .war."
Remove prefix
file folders copied to be filtered, such as the figure above target folder.
Remote directory
file to get the file on the remote machine folder, this folder is relative to the "SSH Server" in the "Remote directory" of. Assuming that there will take the initiative to create their own.
Exec command
here can fill out a script that runs on the machine fortune, such as: application deployment script

Here is copying the file directly to svn posted on nginx release directory, remote directory can be modified other, and then run the command can also be copied to the nginx, this method is relatively safe

This is pre-release nginx
Published by jenkins build common website (jenkins + nginx + svn)
modify files files to svn
Published by jenkins build common website (jenkins + nginx + svn)

Click construct
View log
Published by jenkins build common website (jenkins + nginx + svn)
to refresh the page, publishing success
Published by jenkins build common website (jenkins + nginx + svn)

Guess you like

Origin blog.51cto.com/jiaxinwang/2465213