test server
Prepare a test server (Linux)
You only need to install JDK on this test server
Next, what we need to do is to publish the jar package obtained by running it before (Jenkins (2)) to this server and run it automatically.
Install plugin (publish over ssh)
We installed the Maven plug-in before
We now need to install the "publish over ssh" plug-in
Follow the previous steps to install this plug-in, as follows:
Successful installation
Reconfigure
Return to the Dashboard and click the project name "first"
After that, the following interface will appear, select Configuration
After clicking the "Configuration" option , the following content appears, click "Post Steps" directly to enter the following page
Post Steps
In this option, select "Send files or execute commands Over SSH". This is the plug-in we installed before. After clicking, the following content that we need to configure will appear.
Now, this server address cannot be selected yet, so we first need to configure it.
Configure System (add a target server)
Select global configuration,
In this, find "publish over ssh"
Next, click "New"< a i=3> The following interface appears Enter the server name (xxx), ip (such as xx.xx.xx.xx), account (root), Remote Directory (optional)
Scroll down and select "User xxx"
Just enter the password of the previous account in "Passphrase / Password". You don't need to worry about the other things in this tab.
After filling in the above, scroll down and you can select the port, etc.
Scroll down again, here you can set up the springboard machine, etc.
After all settings are completed, there is a Test Configuration, click to try to see if you can connect
Run successfully
If it fails (the password is entered incorrectly), the following content will appear
Change setting
Go back to where you set Post Steps before, and now you can select the server, as follows
Scroll down and configure the source file: throw all jar files in the current directory to the server configured above
Ignore the following two "Remove xx" for now.
"Remote directory": Which directory to send the previously sent files to. If this directory does not exist, it will automatically create a directory.
Exec command: After the transmission is completed, on the target server, you want to execute the above command
Here, simply enter a line of command "echo 1"
Afterwards, save
implement
Execute it again
Check the console output
Find out by checking the logTransferred 0 file(s)
It means that not a single file has been transferred.
But looking at the log, the jar package has been packaged successfully.
I checked the log again and found that there was an error in the "Source files" set previously.
Modify the configuration to: match all directories, all jar packages starting with demo
Rerun
View log
Whether the file has been transferred
It can be found from the log that the file was transferred. You can view the file by entering the test server, and there is no problem running it.
View Files
View catalog
Other issues modified
There was a problem with the directory passed before, so we still need to modify the previous configuration.
- Modify root/root/xxx to root/xxx
- Modify the previous /demo-1/target and change it to root/xxoo/xx.jar
Delete the contents of the directory that reported errors before
Save, then re-run and find that the problem is solved
jar package location
automatic running
This configuration should be modified based on the previous configuration.
Save it and delete the corresponding files on the test server.
Then run it directly
Check the console output
Now the jar package has been started