Jenkins is a Java-developed, open source, and very easy to use continuous integration tool. It can help us realize automated deployment environment, testing, packaging, etc., and can also send us an email notification after the construction task is successful or failed.
What is continuous integration? It means being able to run a task repeatedly and last.
Download and install Jenkins
The download address of Jenkins is https://jenkins.io/download/. When downloading, you can choose each version and the corresponding operating system version. Generally, you can download a common .war file when downloading. This can run on any operating system, but the premise is that you need to install jdk, because Jenkins is developed in Java.
The Jenkins used in this blog is version 2.17, and the jdk version is 1.7. If you download the latest Jenkins version on the official website, you need 1.8 jdk, otherwise you may fail to start Jenkins.
The picture below is a screenshot of the .war file on Jenkins' official website.
After downloading, it is very easy to start Jenkins. Enter the directory where Jenkins is located in the command line, and then execute java -jar jenkins.war to start. This method is easy to use in linux, mac, and Windows.
After starting, look at the logs in the command line, and finally display Jenkins is fully up and running. Jenkins is successfully launched.
cd Desktop #Download to desktop, cd to desktop java -jar jenkins.war #Start Jenkins
Below is a startup screenshot
Screenshot of successful startup
Jenkins installation is successful.
Access Jenkins, Jenkins configurations
The default port number of Jenkins started in the same way just now is 8080. If you access Jenkins, it is your ip:8080. Mine is started locally, so I use localhost:8080 to access it. If you are deploying on your server, then you have to write the IP of your server to access it.
When you open Jenkins for the first time, it will allow you to unlock and enter the initialization password of admin. This password is prompted on the page. In a directory on the c drive, go to the c drive to find it, open it with txt, copy it, and fill it in, as shown below:
After filling in the initial password, you will be asked to select the plug-in. Should you choose the recommended plug-in or custom plug-in? Let's just select the recommended plug-in. Install the remaining plug-in. It will automatically install these plug-ins. The plug-in process may be longer, so be patient, as shown in the figure below:
The following is the installation plugin page
After the plug-in is installed, you need to enter the username, password and email address of an administrator. Remember here. You must use this to log in in the future. You cannot write the email address randomly. You must write the email address you use to send emails in the future, otherwise the email will fail.
Only then can the installation and basic configuration of Jenkins be truly over. Here is what you see when you log in
Jenkins configure email sending
Log in with the admin user, find the global settings in Jenkins system management. There is Jenkins Location in the global settings, and there is a system administrator email address below. Write this as the email address you entered when you created the admin user just now.
Then continue to search, find the email notification, and then click the advanced below the email notification. This is the place to configure email sending.
The smtp server is the address of the smtp server. You can write the smtp server of the mailbox that you use.
To check the use of SMTP authentication, here is to enter the account and password of the email address. Note that both the QQ email address and the 163 email address must be entered to enter the authorization code. You cannot use the password directly, and you must also enable SMTP in the settings.
If the email address is SSL protocol, then you need to check the SSL protocol, for example, the qq mailbox uses the SSL protocol.
There is also an SMTP port number below, so you don't need to write it. Jenkins will automatically write the port number for you. If your email server port number is not the default, the default port number for SMTP is 25, and the default port number for SMTPSSL is 465. If your company's mail server is built by yourself, you have to write it here if the port number is changed.
Below is a screenshot
The email configuration is completed. Let’s test whether it can be successful.
Continue to search for it, there is a test configuration by sending test emails. Tick it up. It will let you enter an email, then click Test configuration, and you can test it. Below you can see that I have received a test email from Jenkins.
Below is a screenshot of the email received.
Finally OK, this is what Jenkins' installation, basic configuration and email configuration are. Go and try it.