[Formerly] Jenkins remote deployment based on the Telnet protocol

Source: Internet
Author: User

Recently ordered to study the automatic remote deployment of Jenkins, just started smoothly. But then the problem comes, and the target machine we're deploying is the Telnet protocol. All of the plugins that have been exposed to Jenkins know that there is only one for local deployment and remote deployment based on the SSH protocol, and none of them is based on the Telnet protocol. So how does this work out?

Of course, you can also install the SSH service for your target machine.

Let me first talk about the solution, and then attach the specific steps and shell scripts.

Idea: Install Jenkins on a Linux system---> SVN check out deployed projects---> Maven plugins compile, Package---> FTP plug-ins that use Jenkins to upload projects or packages that need to be deployed to a specified machine ---> Execute shell scripts to log on to the machine for decompression, deployment, startup, etc. (you can also directly execute the written shell).

Specific steps:

(1) Source management, fill in the corresponding project SVN address and user name password

  

(2) To configure MAVEN build, the configuration of the Maven plugin is set in the system settings.

  

(3) FTP upload

  

Here the source files is the relative path of Jenkins's workspace, and remove prefix is the prefix of the cancellation (only the project name part is retained).

(4) Execute script at build time

  

This is a Telnet logon script.

#!/usr/bin/Env SHUSERNAME=Swdev # Login user name Passward=Swdev # login Password tar=icore-business-ecif-biz-0.0.1-snapshot-unix.Tar. GZ #TAR是上传的压缩包的名字MODEL=Provider # model is the name of the compressed package root directory as well as the binary program name that is launched Deploy_dir=Ecif # deploy_ip is the directory where the files are uploaded remote_ip=192.168.2.3# login IP (Sleep 1;Echo "$USERNAME"; Sleep 1;Echo "$PASSWARD"; Sleep 1;Echo "CD \ $HOME/$DEPLOY _dir"; Sleep 1;Echo "chmod +x./deploy"; Sleep 1;Echo "nohup./deploy $TAR $MODEL 2>&1 > deploy.log&"; Sleep Ten)|telnet $REMOTE _ip exit0

(5) Post-build script deploy.sh (mainly used for decompression, deployment, startup, etc., which is placed in the directory where the files are uploaded)

#!/usr/bin/Env SH## $1 Tar. GZ name# $2Provider source folder Name#set-Elog_message () {Echo "[$ (date +%y%m%d-%h:%m:%s)] $"}basdir=$(dirname$0)if[$#-lt2]; ThenLog_message"Usage: $ (basename $) [tar name] [provider name]"Exit1fi# Stop Previous version and Backup, ThenRemove Previous Packagecmd="$BASDIR/$2/bin/$2"if[-E" $"]; Then$CMD Stop Backup="${2}-$ (date +%y%m%d%h%m%s)"Log_message"Back up previous application to ${backup}.tar.gz"  Tar-CVF $backup.Tar$2  gzip${backup}.Tar  RM-RF $2fiLog_message"Extract Package Begin"Gunzip-C $1|Tar-XVF-# Generate Log directorymkdir-P $BASDIR/$2/Logslog_message"Starting Application"$CMD Start

This script is just an example and needs to be specific to the specific business.

In the end, some of the more pits we encountered were brought out to share with you:

Failed to parse POMs.

  

Cause: A problem with the connection between the local server and the MAVEN server caused the jar package to fail to download and error

Workaround:

Vi/etc/hosts

At the end of the file, add the address you used as: "192.168.1.1 www.nexus.xxx.com"

Run "#/etc/init.d/networking Restart" to restart the network

All right, let's go here and find out what the problem is, let's talk a lot.

  

[Formerly] Jenkins remote deployment based on the Telnet protocol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.