简体   繁体   English

Jenkins 部署插件 - 从属性文件传递参数

[英]Jenkins deploy plugin - pass parameters from properties file

I'm using Jenkins and deploy plugin, with which I'm deploying to tomcat server.我正在使用 Jenkins 和部署插件,我正在使用它部署到 tomcat 服务器。 How can I pass parameters from properties file to this deploy plugin?如何将参数从属性文件传递到此部署插件?

for example I want to pass my property app.server.url to Tomcat URL field.例如,我想将我的属性 app.server.url 传递给 Tomcat URL 字段。

I tried to pass $app.server.url also %app.server.url% , but that doesn't work.我试图通过$app.server.url%app.server.url% ,但这不起作用。

I am assuming you have a properties file in the format app.server.url=somevalue我假设您有一个格式为app.server.url=somevalue的属性文件

You then can inject these properties into the Jenkins environment using EnvInjec Plugin .然后,您可以使用EnvInjec Plugin将这些属性注入到 Jenkins 环境中。 Use Inject environment variables for your job build step, and just specify your file path (leave the content field blank).为您的作业构建步骤使用注入环境变量,只需指定您的文件路径(将内容字段留空)。 After that, you can reference it like this $app.server.url for *nix, or %app.server.url% for Windows.之后,您可以像这样引用它,例如 *nix 的$app.server.url或 Windows 的%app.server.url% However this only works on the shell level.但是,这只适用于外壳级别。 On the plugin properties level, a lot of plugins are expecting properties only in *nix-style format.在插件属性级别,许多插件只期望 *nix 样式格式的属性。

The further problem is that *nix-style variables do not allow dots .进一步的问题是,* nix的风格变量不允许. . . So $app.server.url is not valid on *nix.所以$app.server.url在 *nix 上无效。 I do not know if it will work on plugin-level on Windows though.我不知道它是否可以在 Windows 上的插件级别上工作。

So after setting up EnvInject plugin, try the following two:所以设置EnvInject插件后,尝试以下两个:

  • Try using $app.server.url in your deploy plugin.尝试在您的部署插件中使用$app.server.url
  • Else change the property file to something like app_server_url=somevalue , and then try $app_server_url in deploy plugin.否则将属性文件更改为app_server_url=somevalue ,然后在部署插件中尝试$app_server_url

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM