Jenkins Build with Parameter and authentication 但没有参数值

Jenkins Build with Parameter and authentication but no parameter value

我已经尝试了多种方法来通过身份验证和参数(从带有参数插件的构建)自动传递 URL 以通过 wget 命令远程启动作业:

/usr/bin/wget --auth-no-challenge --http-user=<http-user> --http-password=<password like> http://<IP>:8080/job/<jobName>/buildWithParameters?token=<tokeName>&<param1>=<text1>

非参数化版本 运行 运行顺利,没有任何问题,但是必要的 <param1> 无法用于作业。

在带参数的构建作业中设置默认值,运行顺利完成作业,但违背了通过脚本远程 运行ning 的目的。

这是经过清理的输出:

Started by remote host x.x.x.x
[EnvInject] - Loading node environment variables.
[EnvInject] - Preparing an environment for the build.
[EnvInject] - Keeping Jenkins system variables.
[EnvInject] - Keeping Jenkins build variables.
[EnvInject] - [ERROR] - The given properties file path '/var/lib/jenkins/<paramsFolder>/.properties' doesn't exist.
[EnvInject] - [ERROR] - Missing file path was resolved from pattern '/var/lib/jenkins/<paramsFolder>/${NAMESTR}.properties' .
ERROR: SEVERE ERROR occurs
org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException: The given properties file path '/var/lib/jenkins/<paramsFolder>/.properties' doesn't exist.

在作业的配置中,NAMESTR 被定义为字符串参数。当给定正确的默认值时,作业 运行s 如预期的那样。如果作业中没有默认值,则参数值无法通过作业的 wget 命令获得,如上面的输出所示。

我必须有身份验证和命令行方式来为作业提供参数。我无法与 Jenkins 用户界面交互以手动 运行 命令。

有什么想法吗?有解决方法吗?

使用Http request plugin

Select Http 请求 表单 添加构建步骤

将您的 url 粘贴到 URL 字段中

Select POST 来自 Http 模式的方法

如果您想添加身份验证,请将身份验证详细信息更新到您的 Jenkins 配置全局设置

尝试使用 cURL,它对我来说就像做梦一样。

curl -X POST http://localhost:8080/job/test_job/buildWithParameters?RandomUser=Tom --user admin:admin

我发现 wget 选项 --post 数据适用于 BuildWithParameters 插件。

/usr/bin/wget --auth-no-challenge --http-user=<http-user> --http-password=<password like> --post-data 'param1=text1' http://<IP>:8080/job/<job name>/buildWithParameters?token=<tokenName>