jenkins-infra / jenkins.io

A static site for the Jenkins automation server
https://jenkins.io
Other
323 stars 1.24k forks source link

content/doc/book/using/remote-access-api.adoc has errors #4881

Open halkeye opened 2 years ago

halkeye commented 2 years ago

On further review, there are more things wrong with this content, so well out of scope for this PR.

_Originally posted by @daniel-beck in https://github.com/jenkins-infra/jenkins.io/pull/4874#discussion_r796182858_

yozachar commented 2 years ago

Hi, I'm unable to get the expected results following the doc https://www.jenkins.io/doc/book/using/remote-access-api/#submitting-jobs.

I'm trying to send a POST request to a build with parameters.

Method 1

PARAMETRIZED_URL="${BUILD_URL}?delay=0sec&token=${BUILD_TOKEN}"
PARAMETRIZED_URL+="&PARAM_X=${PARAM_X_VAL}"
PARAMETRIZED_URL+="&PARAM_Y=${PARAM_Y_VAL}"

curl --silent --request POST \
    --user ${USERNAME}:${USR_API_KEY} \
    ${PARAMETRIZED_URL} \
    --include --output response

Method 2

curl --silent --request POST \
    --user ${USERNAME}:${USR_API_KEY} \
    --data delay='0sec' \
    --data token="${BUILD_TOKEN}" \
    --data PARAM_X="${PARAM_X_VAL}" \
    --data PARAM_Y="${PARAM_Y_VAL}" \
    "${BUILD_URL}" \  # this is "${JENKINS_JOB_URL}/buildWithParameters"
    --include --output response

Problem

Both of them trigger the job, but fail to send the parameters. In the console output I can see:

...
time="2022-11-02T07:33:44Z" level=warning msg="The \"PARAM_X_VAL\" variable is not set. Defaulting to a blank string."
time="2022-11-02T07:33:44Z" level=warning msg="The \"PARAM_Y_VAL\" variable is not set. Defaulting to a blank string."
...

Where am I going wrong?