Reprint: Http://www.cnblogs.com/EasonJim/p/6295372.htmlJenkins use FTP for one-click Deployment and Rollback 2 (Windows) (Project practice) Prerequisites:
This article is a real project practice following the previous http://www.cnblogs.com/EasonJim/p/6092938.html.
Please refer to the previous article for ideas and approximate steps.
Note: This article relates to two servers: 1 for the test server. 2 for the official server. Also, both servers must have Jenkins installed.
NOTE 2: One-click deployment here refers to the publishing functionality from the test server to the official server.
Tip: If you have permission or error issues with the CLI call, refer to: http://www.cnblogs.com/EasonJim/p/6086018.html
Specific operation: First, the configuration of the official server project
Select "Build a free-form software project" When you choose to build your project
View Original
1, decompression works:
View Original
View Original
View Original
Command line:
echo [INFO] Backup compression operation call C: \ "program Files" \winrar\rar.exe a-x*\upload*-x*\ueditor*-x*\uploadfolder*%filepath%. Bak.rar%unzippath%echo [INFO] decompression operation call C: \ "program Files" \winrar\rar.exe x-ep2-o+-%filepath%%unzippath%
Description
Backup and unzip, that is, every operation before the backup.
1) When deploying, such as uploading a file name of 1.rar, then the backup file is 1.rar.bak.rar.
2. Restoration project:
View Original
View Original
View Original
Command line:
echo [INFO] Backup compression operation call C: \ "program Files" \winrar\rar.exe a-k-r-s-m1-x*\upload*-x*\ueditor*-x*\uploadfolder*-x* \web.config-x*\downloadfile*-x*\errorlog*-x*\logfiles*%filepath%-%build_id%.restorebak.rar%UnzipPath%echo [INFO ] Decompression operation Set "url=%unzippath%" Call C: "program Files" \winrar\rar.exe x-ep2-o+-%filepath%%url:~0,3%
Description
Backup and unzip, that is, every operation before the backup.
0) When I compress, I add buildid as a parameter to avoid repeating problems when I restore the same one.
1) rollback, such as the file name of the uploaded backup is 1.rar.bak.rar, then the rollback operation backup file is 1.rar.bak.rar.restorebak.rar.
2) here because the above backup of the compression package is the full path, so I use the string cut extract to the drive letter extracted directly.
Second, the Configuration test Server Project 1, one-click Deployment Engineering:
Select "Build a free-form software project" When you choose to build your project
View original 1) configuration engineering Information:
View original 2) Configure batch processing for compression:
View Original
Description: The rules are named here, and will eventually be copied to workspace because the FTP upload software only supports the current workspace directory.
The batch process is as follows:
echo [INFO] compresses the files to be uploaded, some files have been excluded here CD D:\wwwroot\nhq\wwwroot callC: \ "program Files" \winrar\rar.exe a-k-r-s- m1-x*\upload*-x*\ueditor*-x*\uploadfolder*-x*\web.config-x*\downloadfile*-x*\errorlog*-x*\LogFiles*-ag{%BUILD_ Id%.push} D:\wwwroot\nhq\wwwrootmove%build_id%.push.rar%workspace%
3) Configure FTP upload:
View Original
The server selected on "Name" needs to be configured manually, as follows:
Installing the plugin "Publish over FTP"
In System management, system settings, Publish over FTP, click the Add button to add an FTP to connect to:
View Original
Attention:
"Source files" represents not the absolute path, but the path of Jenkins's workpase, equivalent to the relative path, if you want to upload the entire directory including subdirectories, and finally add "\**";
"Remove prefix" means to remove the directory prefix, if not removed, will be created according to the above directory.
"Remote directory" is the FTP storage directory, and if none of the above directories will be created automatically.
"Exclude files" is a reference for the files and folders to be excluded.
4) Configure the Invoke service for the CLI:
Note: This is the CLI service that calls the official server directly.
View Original
The batch process is as follows:
echo [INFO] calls the public network Jenkins through the CLI to unpack Java-jar "C:\Program Files (x86) \jenkins\war\web-inf\jenkins-cli.jar"-S/http 192.168.199.1:8080/build unzip-p filepath=e:\wwwroot\inetpub\bak\%build_id%.push.rar-p UnzipPath=E:\wwwroot\ Inetpub\wwwroot\testbank--username Administrator--password Administrator
Parameter descriptions refer to the instructions above.
5) Configure Mail sending:
View Original
The trigger point is sent regardless of the result.
View original 2, one-click Rollback project:
Select "Build a free-form software project" When you choose to build your project
View original 1) configuration engineering Information:
View original 2) configuration build selection Parameters:
View Original
Tip: Project Here is the one-click Deployment project configured above to automatically identify the build ID.
3) Call the CLI for a rollback of the build environment:
View Original
The batch process is as follows:
Echo[INFO] Call the public network Jenkins to unpack via CLISetlocalEnabledelayedexpansionset url= "%projectname%"Set "buildid="set Url=%url::=/%set url=%url:///=/%set url=% url://=/%for/f "tokens=1,2,3,4,5,6* delims=/"%%a in (%url%) Do ( set "buildid=%%f")Java-jar "C:\Program Files (x86) \jenkins\war\web-inf\jenkins-cli.jar"-S/http 192.169.199.1:8080/build restore-p filepath=e:\wwwroot\inetpub\bak\%buildid%.push.rar.bak.rar-p UnzipPath=E : \wwwroot\inetpub\wwwroot\testbank--username Administrator--password Administrator
Tip: The batch cut used above gets buildid, which specifies which version to roll back.
4) Configure email notification:
View Original
Trigger point:
View Original
Here, the configuration is all done.
Jenkins uses FTP for one-click Deployment and Rollback 2 (Windows) (Project practice)