In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to deploy the project to the remote machine through the Publish Over SSH plug-in in jenkins. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Publish Over SSH plug-in use
Before using Publish Over SSH, you need to make a SSH private key. Do secret-free login configuration between machines. Suppose that machine An is 192.168.AA.AAA and machine B: 192.168.BB.BBB. Machine A can log in to machine B without secret, and machine B can log in to machine A without secret. The production method is as follows:
Enter machine An and execute:
Cd ~ ssh-keygen-t rsa
Use the following command to indicate that you can log in to the machine 192.168.BB.BBB through the machine 192.168.AA.AAA.
Ssh-copy-id 192.168.BB.BBB
The verification method is to execute ssh 192.168.BB.BBB on machine A, and then execute ifconfig to check the current ip. If it is found that the ip of the machine has become 192.168.BB.BBB, it means that the secret-free login setting is successful.
Enter machine B and execute:
Cd ~ ssh-keygen-t rsassh-copy-id 192.168.AA.AAA
The verification method is to execute ssh 192.168.AA.AAA on machine B, and then execute ifconfig to check the current ip. If it is found that the ip of the machine has become 192.168.BB.BBB, it means that the secret-free login setting is successful.
Configure Publish Over SSH in the system configuration
Go to Jenkins--> system Administration-> system Settings and configure Publish over SSH
Parameter description:
Passphrase: password (password for key, if you set it)
Path to the Path to key:key file (private key)
Key: copy the private key to this box
Disable exec: disable running command
Private configuration:
SSH Server Name: the name of the logo (whatever you choose)
Hostname: the hostname or ip address that needs to connect to the ssh (recommended ip)
Username: user name
Remote Directory: remote directory
Use password authentication, or use a different key: public configuration can be replaced (what is selected is the public configuration, which is very scalable)
Advanced private configuration:
Port: Port (default 22)
Timeout (ms): timeout (milliseconds) is available by default
Disable exec: disable running command
Test Configuration: testing connection
Configure the SSH in the built project:
Before execution, cooperate with the Execute shell configuration in Build- > Post Steps, execute the scp command, and copy the items to be copied remotely to the remote machine. The content in Execute shell is as follows:
Scp-r / root/.jenkins/workspace/youxuan_api_pre/qt360-web/target/youxuan_api root@192.168.BB.BBB:/usr/local/jenkinsTempFolder/export BUILD_ID=DONTKILLME
Click "build Project"-> "configure"-> "Post-build Operation", select Send build artifacts over SSH, and configure as follows (Note: the following Exec command is a script executed on the remote machine):
The script reads as follows:
#! / bin/bashecho "= start deploy project=" ps-aux | grep / usr/local/tomcat/ | grep-v grep > tomcat_info.txtsed 's / / / g 'tomcat_info.txt > tomcat_info1.txtsed 's / / / g 'tomcat_info1.txt > tomcat_info.txtsed 's / / / g 'tomcat_info.txt > tomcat_info1.txt cat tomcat_info1.txt | cut-d'- f 2 > tomcat_info.txtfor line in `cat Tomcat_ info.txt`do kill-9$ linedonecd / usr/local/tomcat/webappsrm-rf youxuan_api*mv / usr/local/jenkinsTempFolder/youxuan_api / usr/local/tomcat/webapps/etc/init.d/tomcat startsyncecho 3 > / proc/sys/vm/drop_cachesecho "= deploy project success="
Parameter description:
SSH Server Name: choose the name of a configuration that you configure in the system settings
Transfer Set Source files: the file to be uploaded (Note: the path relative to the workspace. Look at the configuration below, you can fill in more than one, used by default, separated)
Remove prefix: remove directories (only directories in Transfer Set Source files can be specified)
Remote directory: remote directory (fill in according to your requirements, because I am here for testing, so lazy did not fill in. System configuration is inherited by default)
Exec command: write down the command you are going to execute in it
(the new version requires that both Transfer Set Source files and Exec command should be filled in, but not him. Only one is allowed in the old version)
Advanced:
Exclude files: excluded files (useful when you transfer directories, use wildcards, such as * * / * .log, * * / * .tmp, .git /)
Pattern separator: delimiter (the delimiter that configures Transfer Set Source files. If you change it here, the above content also needs to be changed)
No default excludes: disable default exclusion rules (see help for yourself)
Make empty dirs: this option changes the default behavior of the plug-in. The default behavior is to match whether the file exists, and if so, create a directory to store it. Selecting this option directly creates a directory to store files, even if it is an empty directory. (personal understanding)
Flatten files: only upload files, do not create directories (except remote directories)
Remote directory is a date format: create a folder with a date in the remote directory (you need to configure the date format in Remote directory). For more information, please see the following table:
Remote directory Directories created
'qa-approved/'yyyyMMddHHmmss qa-approved/20101107154555
'builds/'yyyy/MM/dd/'build-$ {BUILD_NUMBER} 'builds/2010/11/07/build-456 (if the build was number 456)
Yyyy_MM/'build'-EEE-d-HHmmss 2010_11/build-Sun-7-154555
Yyyy-MM-dd_HH-mm-ss 2010-11-07 15-45-55
Exec timeout (ms): timeout for running steps (milliseconds)
Exec in pty: simulates the execution steps of a terminal
Add Transfer Set: add a configuration
On "how to deploy the project to the remote machine through the Publish Over SSH plug-in in jenkins" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.