mockersf / jenkins-api.rs

Rust client for Jenkins API
MIT License
26 stars 17 forks source link

Feature: simultaneous token and paramter support for job builder #62

Open jmrgibson opened 3 years ago

jmrgibson commented 3 years ago

I'm not sure why this is unsupported, but I'm happy to have a go at implementing it.

I have the following curl command that works, but I'm unable to use the rust api because it doesn't support the token and the params at the same time

curl -v --trace-ascii - --trace-time -X POST "${JENKINS_PROTOCOL}://${JENKINS_DOMAIN}:${JENKINS_PORT}/job/${JENKINS_JOB}/build" \
    --retry 3 \
    --retry-delay 20 \
    --data token="${JOB_TOKEN}" \
    --data-urlencode json='{"parameter": [
        {"name":"A_PARAM", "value":"1234"},
        {"name":"ANOTHER_PARAM "value":"5678"},
    ]}'
mockersf commented 3 years ago

this wasn't supported because I didn't try sending the token in the body instead of a query parameter, which didn't work 👍

I pushed a fix that should do the same thing as the curl request you posted, could you check if it works for you?

jmrgibson commented 3 years ago

yup, sorry for the delay, but that works fine. It's also may worth mentioning in the docs that the "password" section of the with_auth() param can also be a API token (which actually works much better than the job tokens this implementets)