当前位置:网站首页>Jenkins pipeline's handling of job parameters
Jenkins pipeline's handling of job parameters
2022-06-28 20:04:00 【51CTO】
List of articles
One 、 Judge whether the parameter value is empty
Job Build with parameterization , Configuration parameters DOCKER_HOST and DB_HOST, Now you need to groovy Determine whether their values are empty in the script 
1.1. The script content
explain :
1.2. Execution results

Two 、 When the value of the parameter is several IP Address , How to extract ?

2.1. Script
explain :
2.2. Execution results

3、 ... and 、 hold Job Parameters are written to /etc/ansible/hosts file

Script
#
!
groovy
def
filePath
=
"/etc/ansible/hosts"
def
backupPath
=
"/etc/ansible/host_bak"
def
logTime
=
new
Date().
format(
'yyyyMMddHHmmss')
// Extract current timestamp
if(
!
fileExists(
backupPath)) {
sh
"mkdir ${
backupPath
}"
}
if(
fileExists(
filePath)) {
sh
"mv ${
filePath
} ${
backupPath
}/hosts_bak_${
logTime
}"
// perform Shell command
}
outFile
=
new
File(
filePath)
// Turn the file into a File class
def
dockerIpList
=
this.
DOCKER_HOST.
split(
",")
// Separate with commas , And save it in the list
outFile.
append(
'['
+
'DOCKER_HOST'
+
']\n')
// If the file doesn't exist , Will create
for (
ip
in
dockerIpList) {
outFile.
append(
ip
+
'\n')
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
Execution effect

边栏推荐
- 【324. 摆动排序 II】
- Time series forecasting based on trend and seasonality
- Kettle (VI): full database backup based on kettle
- Priority problem when local variables and global variables in C language have the same name (when local variables and global variables exist at the same time, local variables are preferred to be refer
- 2788.Cifera
- 计网 | 一文解析TCP协议所有知识点
- Bluecmsv1.6 code audit
- csdn涨薪技术-Selenium自动化测试全栈总结
- 5g NR MBS architecture introduction
- Industry analysis - quick intercom, building intercom
猜你喜欢
![return new int[]{i + 1, mid + 1}; return {i + 1, mid + 1};](/img/6a/45a4494276deba72ef9833818229f5.png)
return new int[]{i + 1, mid + 1}; return {i + 1, mid + 1};

Markdown mermaid种草(1)_ mermaid简介

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 C1047 对象或库文件“.lib”是使用与其他对象(如“x64\Release\main.obj”)不同的

Markdown drawing Mermaid practical tutorial

Time series forecasting based on trend and seasonality

Bluecmsv1.6 code audit

Bayesian inference problem, MCMC and variational inference

Double contextual relationship network for polyp segmentation

Xiaobai's e-commerce business is very important to choose the right mall system!

数字藏品,万字长文,你想知道的大部分问题都讲清楚了从业者必看
随机推荐
Tcwind mode setting
Pyinstaller打包pikepdf失败的问题排查
R language GLM generalized linear model: logistic regression, Poisson regression fitting mouse clinical trial data (dose and response) examples and self-test questions
Bayesian inference problem, MCMC and variational inference
压缩与解压缩命令
2022年4月10日--使用C#迈出第一步--使用C#从.NET类库调用方法(没看懂)
Markdown mermaid種草(1)_ mermaid簡介
Xiaobai's e-commerce business is very important to choose the right mall system!
Compression and decompression commands
QSP读取标签配置错误问题
ROS中quaternion四元数和欧拉角转换
rsync远程同步
图神经网络入门 (GNN, GCN)
Redis 如何实现库存扣减操作?如何防止商品被超卖?
ArrayList of collection
Figure introduction to neural networks (GNN, GCN)
Class loading mechanism and object creation
On the first anniversary of the data security law, which four major changes are coming?
jvm内存结构
Machine learning notes temperature+softmax