Jenkins Basics - basic settings
Heart like light 2021-06-04 10:49:20

Site settings

Just built Jenkins Environmental Science , You also need to make some simple settings , Let's have Jenkins It seems to be the same thing , Especially when you're going to use it in a production environment . The first is domain name configuration , If you are Jenkins The service assigned a domain name , adopt Nginx Reverse proxy way to access Jenkins service , When you visit Jenkins Of 【 System management 】 You will see the following warning in the interface , The reverse proxy settings are incorrect , Warning has been issued for the following components currently installed :
image.png
We need to go to 【 The system configuration 】 Set it up inside , take Jenkins URL By default IP Change to domain name :
image.png
Still Jenkins Of 【 System management 】 The palette , Click on 【 Configure which warnings to display 】, Or go to 【 Global security configuration 】 Set it up inside , find 【 Hidden security warnings 】 This place , stay 【 Safety warning ...】 It hides these warnings :
image.png

For security warnings, the best thing to do is to upgrade Jenkins edition , But the new Jenkins Interface management is quite different , Let's hide these warnings for a while , I've had a good time Jenkins We can use the new version later Jenkins.

Tool configuration

We make use of Jenkins There may be other tools needed to build our project , For example, build Java Project needs JDK,Ant Managed projects need Ant Tools ,Maven Managed projects need Maven Tools ,Gradle Managed projects need Gradle,nodeJs Project needs Node and Npm etc. . We need to download these tools to the offline installation package first , Unzip to Jenkins Directory that can be accessed , Put special emphasis on , It is not recommended to use the tools we need to install the system globally , Otherwise, some projects need different versions of the tool , That's going to be a lot of trouble . Use offline installation package to put in different directory , It's very convenient to switch tool versions . In addition to Maven perhaps Gradle project , Recommended Maven Wrapper perhaps Gradle Wrapper, This allows the project to decide which version of the tool to use .
Jenkins The default running environment is OpenJDK, If our project needs to be built with OracleJDK, Then we'll go Oracle Download specific JDK edition . for example , I downloaded one here OracleJDK 1.8.0_241, Put it in /var/jenkins_home/software/jdk1.8.0_241 Catalog , One is ready Maven, stay /var/jenkins_home/software/apache-maven-3.6.3 Catalog .
If you don't want to download and install the offline package yourself , I don't want to install these tools in the system , You can also choose to go to Jenkins Of 【 System management 】 Medium 【 Global tool configuration 】 Inside , This interface can set the required software , Currently, configuration and installation are supported JDK、Git、Gradle、Ant、Maven Tools such as . For example, I have a JDK Installation , Click on 【 newly added JDK 】 Button , Fill in JDK Alias , Choose good JDK edition , Currently supported JDK Version from 1.4 To JDK 9 There are , I'll take the latest one here JDK 8, Use JDK Consent required Oracle License agreement for , Consent to the license agreement requires logging in Oracle account number , Currently in Oracle Download from the official website JDK Also need to log in , No, Oracle Just sign up for an account , Log in directly if you have an account ,Jenkins It also integrates the login function .
【 Global tool configuration 】 It can support adding the following tools :
image.png
Add one JDK, choice JDK 8:
image.png
Sign in Oracle account number , agree! JDK License agreement for :
image.png

environment variable

adopt 【 Global tool configuration 】 The added tools can be found in Jenkins It's directly used in the task of , You don't have to set environment variables . If it's a tool you install by decompressing the offline package , In order to make Jenkins To know where our tools are , This requires the use of environment variables . Still Jenkins【 The system configuration 】 Inside 【 Global properties 】 below , There is one 【 environment variable 】 Check box , Check on , Add environment variable key value pair , For example, I set up JDK and Maven Environment variables of :
image.png
It's going on Maven It can be used when building packages $MAVEN_HOME/bin/mvn clean  package Conduct Maven pack , It can also be used. export Command to temporarily adjust environment variables :

[jenkins@asus-centos ~]$ export MAVEN_HOME=/var/jenkins_home/software/apache-maven-3.6.3
[jenkins@asus-centos ~]$ $MAVEN_HOME/bin/mvn -version

matters needing attention

stay Jenkins The tools used in this project can be 【 Global tool configuration 】 Or you can install it offline and configure environment variables , But please choose between the two ways , If you set up 【 Global tool configuration 】 I added environment variables myself , Strange problems may arise .
our Maven and Gradle When accessing some private product warehouses, you need to configure the account and password , When in Jenkins When packaging is performed on a node Jenkins Under the system account of the node .m2 perhaps .gradle Catalog to find , So we also need to Jenkins The master node Maven settings.xml perhaps Gradle init.gradle Get a copy of the configuration file to the user directory of other nodes .m2 perhaps .gradle Directory .

Please bring the original link to reprint ,thank
Similar articles

2021-08-09

2021-08-09