Install Jenkins

Download address, https://jenkins.io/download/, just download the war file to download good Jenkins. War in tomcat/webapps directory, then start tomcat.

2. Jenkins configuration

After startup, visit: http://192.168.14.131:8888/jenkins, here to own the IP and port, to appear the interface for the following:

Has been offline interface don’t move, and then open a new TAB, enter http://192.168.13.131:8888/jenkins/pluginManager/advanced. There a 【 upgrade site 】 the bottom, it is good to change the link to HTTP, http://updates.jenkins.io/update-center.json. Then restart Tomcat, refresh the interface, so that the normal network can be connected.

Select the recommended plug-ins to install

Create the first administrator user

Click save and finish to enter the instance configuration and configure Jenkins’ access path

Click Save and finish. Jenkins is ready

It will then jump to the login screen

Possible problems:

Jenkins set the administrator account and password after the initial configuration. The webpage stays for a long time, and the login cannot be refreshed.

Solutions:

Find the.Jenkins /config.xml file: (The Windows environment is under the same directory as initialsecretPassword, If the direct use of the installation package to install the file exists in the installation directory/config/config. The XML) (Linux operating system installation in/root /. Jenkins/config. XML)

Look at this value:

authorizationStrategy class=”hudson.security.FullControlOnceLoggedInAuthorizationStrategy”

This permission corresponds to logged-in users can do anything. I don’t know why I can’t log in so I can’t do anything.

Replace with class = “Hudson. Security. AuthorizationStrategy $Unsecured”

This permission corresponds to “any user can do anything (without any restrictions)”

After logging in to see the system management, the main is to configure the right three: system Settings, global tool configuration, plug-in management

1. Configure Jenkins plug-ins

Prior to this step, most of the plugins were already installed when Jenkins was first booted, so we just need to check if the following plugins are installed

  1. Maven Integration allows us to start a Maven project as a task
  2. The Git plugin allows you to read projects stored in a Git repository
2. Configure Jenkins Global tool
The global tools for Jenkins configuration are mainly JDK, Git, Maven and so onCopy the code

I do not use automatic installation of JDK, Git, and Maven. They are all installed on Linux.

Linux install Git

The general installation steps are as follows:

(1), https://github.com/git/git/releases’s latest Git installation package download links, the Linux server, download, command as follows: Wget HTTP: / / https://github.com/git/git/archive/v2.17.0.tar.gz;

②, decompress the package and run the following command: tar -zxvf v2.17.0.tar.gz;

③ Install the compiled source code required by the command: Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel GCC perl -extutils-makemaker yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel GCC perl -extutils-makemaker

Yum remove Git: yum remove Git: yum remove Git: y

Make prefix=/usr/local/git all =/usr/local/git all =/usr/local/git all

Make prefix=/usr/local/ Git install; /usr/local/ Git install

Vim /etc/profile = vim /etc/profile

export PATH=/usr/local/git/bin:$PATH

Then save and exit!

The source command takes effect immediately: source /etc/profile

8. Run the git –version command to check the installed git version.

3. Create a task

Create a new task, enter a name, select the Maven project, and click OK

After creating a task, select configuration

Source code management

Select Git and type in the github project address you want to download (the project here is private) as your own project. The red characters appear because the user name and password are not filled in. Click Add, and the following interface will appear.

Enter the user name and password:

After filling in, the following interface is displayed.

Build environment

In the build environment, select “Add timestamps to the Console Output”. The logs will be printed during the code build

Enter the pre-pack MVN command in Build as follows:

Configure a Maven-style project and then configure root poM to point to the top-level pom.xml,

clean install -pl xsjt-comp-manager -am -amd -Pdev -Dmaven.test.skip=true
Copy the code

This way, the XsjT-comp-Manager jar will be built separately, and the dependencies will be built as well, without having to put the dependencies into maven’s repository ahead of time, let alone build a private server. The structure of my project is as follows:

Post Steps

Post Steps Select Run Only if build succeeds

Build immediately

Click Build Now, then select the latest one in Build History and click

Click enter to see the console output on the left, click, you can see the log print record

Problems encountered: [Java service did not start after Jenkins built successfully]

The root of the problem was that Jenkins used processTreeKiller to kill all child processes, which was Jenkins’ default behavior. To solve this problem, we need to add this sentence before booting

BUILD_ID=DONTKILLME
Copy the code

To keep Jenkins from killing our process.

And you’re done!