如何从Jenkins向Rundeck传递参数?新手传递IP参数失败求助
Troubleshooting Jenkins-to-Rundeck Parameter Passing Issue
Hey there! Let's work through this parameter passing problem step by step—this is a common gotcha when first integrating Jenkins and Rundeck, so I’ll walk you through exactly what to check and fix:
1. First, Make Sure Rundeck is Ready to Receive the Parameter
You can’t pass a parameter to Rundeck if the job isn’t set up to accept it. Here’s how to fix that:
- Open your Rundeck job and go to Edit mode.
- Navigate to the Workflow tab, then click Add Parameter.
- Create a parameter named
ip_address(this name must match exactly what you’re sending from Jenkins—case-sensitive!), set the type to String, and add a default value like127.0.0.1for testing. - Save the job changes.
2. Fix the Jenkins Rundeck Plugin Configuration
This is where most people trip up—your parameter format in Jenkins is off. Here’s the correct setup:
- In Jenkins’ post-build action for Rundeck, look for the Job Options (or "Arguments") field.
- Instead of
ip_address=$IP_ADDRESS, you need to use the format-ip_address ${IP_ADDRESS}. The leading dash is critical—Rundeck expects options to be passed with-optionName valuesyntax. - Double-check that you’re referencing Jenkins’ parameter correctly: use
${IP_ADDRESS}(curly braces are more reliable than just$IP_ADDRESSin some Jenkins environments).
3. Correctly Reference the Parameter in Your Rundeck Job
Even if the parameter is sent correctly, you need to call it properly in Rundeck:
- Go back to your Rundeck job’s Workflow, add a Command step.
- Instead of
echo $IP_ADDRESS, use Rundeck’s option reference syntax:echo ${option.ip_address}. This tells Rundeck to pull the value of theip_addressoption you defined earlier. - Test this first directly in Rundeck: run the job manually, input an IP, and confirm the echo step outputs it correctly. This ensures Rundeck’s end is working.
4. Debug with Logs if Issues Persist
If it still isn’t working, dig into the logs to pinpoint where the breakdown is:
- In Jenkins, check the build log for the Rundeck plugin section—look for the actual API call or command it sends to Rundeck. You should see something like
-ip_address 10.10.20.30in the request. - In Rundeck, go to System > Logs to view job execution logs. Look for any errors about unrecognized options, or check if the
ip_addressvalue is being logged correctly when the job runs.
Quick Extra Tips
- Case sensitivity is king! Make sure
ip_addressin Rundeck, Jenkins’ option field, and Jenkins’ parameter name all match exactly (no mixing uppercase/lowercase). - If Jenkins and Rundeck are on separate servers, confirm the Jenkins server can reach Rundeck’s API endpoint (no firewall blocks, correct credentials in the plugin).
- You can test parameter passing directly via Rundeck’s API to rule out Jenkins plugin issues. Use a curl command like:
If this works, the problem is definitely in Jenkins’ plugin configuration.curl -X POST -u your-rundeck-user:your-password http://your-rundeck-server:4440/api/40/job/[your-job-id]/run -H "Content-Type: application/json" -d '{"options": {"ip_address": "10.10.20.30"}}'
内容的提问来源于stack exchange,提问作者Sathish Kumar
相关产品推荐
相关产品推荐

