首页 > 其他分享 >Jenkins的PublishOverSSH插件的Lable用法

Jenkins的PublishOverSSH插件的Lable用法

时间:2023-02-16 14:14:11浏览次数:69  
标签:Lable 插件 param server current SSH Jenkins Label expression

插件准备

项目配置

  1. 参数插件Parameterized Trigger的配置image-20230216133211920

  2. Publish Over SSH配置

    常规配置

    如下图,总共配置了两个服务器,Lable分别是server_1,server_2.

    image-20230216133506242

    image-20230216133417630image-20230216133527411

关键配置:

image-20230216134123114

image-20230216134241419

使用测试

## 参数为server_1时
+ echo current param :server_1
current param :server_1
SSH: Publishing to [test-130] - Label [server_1] matches expression [server_1]
SSH: Skipping [test-130] - Label [server_2] does not match expression [server_1]
## 参数为server_2时
+ echo current param :server_2
current param :server_2
SSH: Skipping [test-130] - Label [server_1] does not match expression [server_2]
SSH: Publishing to [test-130] - Label [server_2] matches expression [server_2]
## 参数为server_.时  配置的两个Server都执行了
+ echo current param :server_.
current param :server_.
SSH: Publishing to [test-130] - Label [server_1] matches expression [server_.]
SSH: Publishing to [test-130] - Label [server_2] matches expression [server_.]

踩坑

官方说明

Parameterized publishing

The same label can be used multiple times, e.g. UAT for a database server and again for the web server.
The regular expression syntax is the java syntax.

The labels can use the standard Jenkins environment variables e.g. $NODE_NAME, or build variables such as a matrix axis.

上面是官方的一段话,说这个参数可以是正则表达式,语法跟Java中一致,但是我误认为这个指的是Lable的配置是正则,这个是错误的理解,实际应该是Parameterized Trigger里面的选择项都是正则。

标签:Lable,插件,param,server,current,SSH,Jenkins,Label,expression
From: https://www.cnblogs.com/xysgo/p/17126445.html

相关文章