Jenkins - environment variables, node configuration and use of node environment variables

1. Jenkins environment variables

Jenkins environment variables are global variables exposed through the env keyword and can be used anywhere in the Jenkins file
insert image description here

1. Classification of environment variables

a. System built-in environment variables

BUILD_NUMBER
BUILD_URL
JOB_NAME
GIT_URL

b. User-defined environment variables

Global environment variable entry Dashboard -> System Management (Manage Jenkins) -> System Configuration (Configure System) -> Global Properties

insert image description here

2. Use of environment variables

Linux deployment: $ variable name
Windows deployment: % variable name%

insert image description here

3. Console output

insert image description here

2. Jenkins node configuration

The built-in node (built-in or master) built by docker lacks many environments and
requires multiple machines to execute Jenkins tasks at the same time.
Different Jenkins tasks have different operating environment requirements.

1. Common nodes of Jenkins

Built-in node
SSH node
Java web node

2. Preparation

java environment
firewall settings
connection username/password

3. SSH node configuration

insert image description here

4. Java web node configuration

insert image description here

5. Java web node configuration detailed steps

https://blog.csdn.net/YZL40514131/article/details/130142810

3. Jenkins node environment variables

When Jenkins is building, if you use a node to build, there may be some personalized environment variables, which need to be managed separately in the node

1. Node tool configuration

The order of use of node tools Node tool > Global tool Node
insert image description here
tool configuration method First configure the global tool, then configure the node tool
Global tool path Dashboard -> System Management (Manage Jenkins) -> Global Tool Configuration (Global Tool Configuration)
node tool configuration path Dashboard -> System Management (Manage Jenkins) -> Node Management (Manage Nodes and Clouds) -> Configure Slave Node -> Node Properties -> Tool Location

insert image description here
insert image description here

2. Node environment variable configuration

The order of use of node environment variables Node environment variables > Global environment variables Global environment variable
path Dashboard -> System Management (Manage Jenkins) -> System Configuration (Configure System) -> Global properties Node environment
insert image description here
insert image description here
variable configuration path Dashboard -> System Management (Manage Jenkins) Jenkins) -> Node Management (Manage Nodes and Clouds) -> Configure Slave Node -> Node Properties -> Environment Variables

insert image description here
insert image description here

4. Practical exercise - Jenkins Job specified node operation

In the work, the specified node is usually used to run the job, such as windows to execute the ui test.
Specify the path of the node to run the job. Select a job -> Configuration -> General -> Restrict the running node of the project (Restrict where this project can be run)

1. Create a job task

insert image description here

2. Configure the job task

insert image description here
insert image description here

3. Build

insert image description here

4. Console output

insert image description here

Guess you like

Origin blog.csdn.net/YZL40514131/article/details/130148274