jenkins 打印参数
时间: 2023-09-18 12:10:22 浏览: 61
您可以通过以下方式在 Jenkins 中打印参数:
1. 在 Jenkinsfile 文件中,使用 `echo` 命令打印参数。例如:
```
pipeline {
agent any
parameters {
string(name: 'PARAMETER_NAME', defaultValue: 'default_value', description: 'Parameter description')
}
stages {
stage('Print parameter') {
steps {
echo "The value of PARAMETER_NAME is ${params.PARAMETER_NAME}"
}
}
}
}
```
2. 在 Jenkins 构建的 Console Output 中,使用 Groovy 脚本打印参数。例如:
```
def params = binding.variables
println "The value of PARAMETER_NAME is ${params.PARAMETER_NAME}"
```
这段代码需要放在一个 Groovy 脚本中,并在 Jenkinsfile 中通过 `script` 命令执行。例如:
```
pipeline {
agent any
parameters {
string(name: 'PARAMETER_NAME', defaultValue: 'default_value', description: 'Parameter description')
}
stages {
stage('Print parameter') {
steps {
script {
def params = binding.variables
println "The value of PARAMETER_NAME is ${params.PARAMETER_NAME}"
}
}
}
}
}
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)