Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Time:2022-5-8
The contents of this paper are as follows:
  • Use of parameters in Jenkins project
  • Jenkins parameter transfer between different projects

Parameters used within the project

  • Parameter creation
  • Create a project
  • Check in generalThis project is parameterized
  • Click“Add parameter
  • After selection, fill in the parameter name in the name and the parameter value in the option

By parameter type“Choice Parameter”Add as an example:

Step screenshot:

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

This project is parameterized

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Select parameter type
Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Fill in parameter value
  • Parameter use
    After parameter setting, you can use ${parameter name} to use the created parameter
  • Add construction steps and selectExecute shell
  • Enter command
echo ${param}

Step screenshot:

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Parameter call
Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Parameter call
  • implement
  • Select build with parameters and select a parameter to start building.
  • Viewing the console, you can see that the output content is the selected parameter value

Step screenshot:

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

implement

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

output

Transfer of different project parameters

  • Add configuration for item 1
  • To transfer parameters, you need to install it firstParameterized Triggerplug-in unit.
  • choiceTrigger parameterized build on other projects
  • Projects to build content: fill in the name of the project to transfer parameters; Use properties from file fill in the file address written by the parameter.
  • Add echo “paramtest = $param” > jenkinsparam Txt writes parameters to a file.
  • Project II configuration
  • Configure character parameters in the project, and the parameters are consistent with the parameter name in the written file.
  • After completion, you can use the configured parameters in the command

be careful: the name of the triggered item in Item 1 should be consistent with the name of triggered item 2; The parameter name written should be consistent with the value of parameter configuration in Item 2.

Step screenshot:

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Post build steps

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Set items to pass to

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

write file

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Use parameters

Basic use of Jenkins: explanation of parameter call and parameter transfer of Jenkins

Parameter call

Recommended Today

Flutter synthetic games

Flutter synthetic gamesGitHub source address:https://github.com/CZXBigBrother/animals-merge-demo init.gif To realize the function, we need to understand the two shutter controls draggable and dragtarget It can be seen from the literal meaning that draggable can be dragged, and dragtarget is the drag target, which is to receive the control of draggable ddd.png We can only receive controls that […]