Reprint: HTTP://WWW.JIANSHU.COM/P/A7D7DF97FE4B
Jenkins official website deployment Steps
Click on the button to download the current stable version of the war package, the test war package than other installation methods installed Jenkins easier to install Plug-ins
Directly click 2.15.war to download
Throw the war package into the ${tomcat_home}/webapps/directory, start TOMCAT, this way the default home directory is/root/.jenkins/
Initializes the initialization password from the Jenkins initialization log to be stored in the/root/.jenkins/initialadminpassword
After entering the initial password, select Install suggested plugins, otherwise the plugin cannot be found later
Initialization plug-in plug-in installation time is relatively long, and then is to select the required plug-ins
Plug-in management work with OSC git install required plugins
There are a lot of Plug-ins are selected by default installation, so now we need to install a few plug-ins, Git plugin and MAVEN integration plugin, the following is my list of plug-ins:
First screen
Second screen
Third screen
Screen Four
Screen Five
System configuration on screen six
The JDK is omitted here (note that the JDK is required on the server, not the JRE), maven, git installation
Find the global Tool configurations in System management, which includes the configuration of tools such as JDK, Git, maven, etc.
System Management
MAVEN Configuration
JDK Configuration
Git configuration
Note: Please check out the automatic installation, manually install the above tools before you configure to create Git warehouse (git.oschina.net)
Due to insufficient server resources (mainly memory, although now upgraded to 2G, but there are OSC git such a private library, feel that they do not need to build a git server), here no longer elaborate how to create a warehouse, directly to say simple configuration.
Public Key Management
Build the public key on the server where the Jenkins is deployed, because the Jenkins needs to access the GIT repository when it is built, see for how to generate the public key:
Http://git.oschina.net/oschina/git-osc/wikis/%E5%B8%AE%E5%8A%A9#ssh-keys Create a project on the Jenkins that needs to be built
Site Selection maven Project
New Project
Source management, choose Git
SOURCE Management
To fill in the address of the Git warehouse, please select the GIT protocol address
Git warehouse
Check your public key configuration if you see the following
Public key error Causes
Now that you are building the MAVEN project, you need to install MAVEN on the server and make the correct configuration if the following error occurs, that is, MAVEN is not installed or is not configured
MAVEN is not installed or is not configured correctly
Goals and options are the same as local maven, clean package
When the Maven build is released, then how to publish it. When it comes to publishing, it's actually moving the project build results to where it should run. So this will require the use of the publish script.
The following configuration represents scripts executed after the Maven build ended
Build Scripts
# will be applied to stop
#stop. SH #!/bin/bash echo "Stopping springboot Application" pid= ' Ps-ef | grep Model.jar | Grep-v grep | awk ' {print 2} '
If [-N ' 2} ' if [-N ' pid] then kill-9 $pid fi
#replace. SH is used to back up the results of the last build and then move the new build results to the appropriate location
#!/bin/bash # First determine if the file exists, and if so, back up file= "/usr/local/sba/model.jar" if [-F "$file"] then mv/usr/local/sba/model.jar/usr/l Ocal/sba/backup/model.jar. ' Date +%y%m%d%h%m%s ' fi mv/root/.jenkins/workspace/test/target/model.jar/usr/local/sba/ Model.jar
# startup.sh Startup Project
!/bin/sh
echo "Grant Current user Permissions"
chmod 777/usr/local/sba/model.jar
echo "Execute ..."
Java-jar/usr/local/sba/model.jar
Note how you would configure the build script
Build_id=dontkillme nohup/usr/local/sba/startup.sh &
The Springboot project was originally started on the server, directly
Nohup Java-jar Springboot.jar &
, but this configuration is not valid on Jenkins and a solution is found on StackOverflow. The above is Jenkins for Springboot, also can publish to Tomcat, modify the script can be. Go ahead and add some scripting notes tomorrow.
Well, there's a Hello world for Jenkins