Jenkins input pipeline step filled via POST with CSRF - howto?

后端 未结 4 1300
陌清茗
陌清茗 2021-01-12 22:13

I have Jenkins pipeline with an Input step, and I would like to submit this input(single string argument) via a script. So far I am trying with curl, ideally I\'ll be sendi

4条回答
  •  囚心锁ツ
    2021-01-12 22:44

    I managed to resolve this issue.

    Hoping that someone else will benefit from my answer, let me explain how I achieved OPs target.

    All that Jenkis Pipeline input step needs is a properly formatted JSON and OK button caption sent to the right URL.

    So, the proper syntax is:

    curl -X POST -H "Jenkins-Crumb:${JENKINS_CRUMB}" -d json='{"parameter": {"name": "${PARAMETER_NAME}", "value": "${PARAMETER_VALUE}"}}' -d proceed='${SUBMIT_CAPTION}' 'http://j${JENKINS_URL}/job/${JOB_NAME}/${BUILD_ID}/input/${INPUT_ID}/submit'
    

    regards

提交回复
热议问题