As an automated construction tool, Jenkins has very powerful functions. This article mainly records my experience in installing and configuring Jenkins

Jenkins had been installed on ali Cloud server before, but it was installed in the form of WAR package, but the static file could not be found inexplicably when the WAR package was decompressed, and the static file was still missing when it was manually moved to the specified directory, so it was not successfully installed in this way.

Due to the above reasons, when I checked the documents on Jenkins’ official website today, I found that it is possible to install yum directly, so I changed the installation method to see if it is feasible.

The system I selected is Red Hat/Fedora/CentOS, and then I run the following command:

sudo wget -O /etc/yum.repos.d/jenkins.repo [http://pkg.jenkins-ci.org/redhat/jenkins.repo](http://pkg.jenkins-ci.org/redhat/jenkins.repo) sudo rpm --import [https://jenkins-ci.org/redhat/jenkins-ci.org.key](http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key) sudo yum install  jenkinsCopy the code

Install the Jenkins service in our system, so it is easy to start the Jenkins service, execute the following command:

sudo service jenkins start # start
sudo service jenkins stop # stop
sudo service jenkins restart # to restart
Copy the code

Jenkins’ log is saved in /var/log/Jenkins by default. Check the startup log. If it fails, it may be that the Java script is not configured.

Make sure the Java path is correct, then save and exit, so it should start normally, browser to host name: port, enter Jenkins.

3. Configure the first visit to Jenkins, you will be asked to input the password, the saving location of the password will be displayed on the page, usually under the secrets file in the installation directory, check the password and input, enter the plug-in installation step, skip here temporarily, and then create the user interface. Follow the instructions to create a user to enter Jenkins home directory.

First, we went to system administration /Global Tool Configuration to configure Java, Maven and Git, similar to the figure

Go to System Administration/Plugin Management and just install Git Plugin for now. Note that there are a lot of dependent plug-ins that need to be installed.

4. Finish the configuration and then create a new project. Click “Create” on the left, as shown in the picture:

Enter the project name, select the free-style software project, and click OK. Then the configuration of the project, click the name of the project, click the configuration on the left, and choose Git for source management, as shown in the picture:

Trigger is not needed for the time being, and then the main build step, this step I encountered a lot of pitfalls, mainly Linux Shell script is not very skilled, I build as follows:

Here I am using Maven, so the code fetch down is to perform Maven clean and war package operation, I will not go into the following, the command is relatively simple, remember to save at last.

Now you can do a build. Click