Why are builds not being triggered with Build Token Root Plugin?

Issue

  • Builds are not triggered through curl command and I receive an unauthentication message
  • Builds are not triggered and the job is inside a folder

Environment

  • CloudBees Jenkins Enterprise
  • Build Token Root Plugin 

Resolution

Builds are not triggered through curl command and I receive an unauthentication message

This issue usually happen because you didn’t use the escape character ""

For normal builds use:

curl -X POST http://<JENKINS_URL>/buildByToken/build?job=MY_JOB\&token=MY_TOKEN

For builds with parameters you need to use the structure below where Type is the paramter:

curl -X POST http://<JENKINS_URL>/buildByToken/buildWithParameters/build?job=MY_JOB\&token=MY_TOKEN\&Type=Mexican

Diagnostics

Changing the logging level to FINE helped identify the root cause.

build_token_root_logger.png

## Builds are not triggered and the job is inside a folder

As a job name you need to specify the Full Project Name you can get from Jenkins GUI.

So for exampe for the Job below which has as a token mytoken

https://felix.ci.cloudbees.com/job/myfolder/job/build-token-root-plugin-inside-folder/

The right command to trigger the job is:

curl -X POST https://felix.ci.cloudbees.com/buildByToken/build?job=myfolder/build-token-root-plugin-inside-folder\&token=mytoken
Have more questions? Submit a request

5 Comments

  • 0
    Avatar
    Jesse Glick

    The plugin logs a detailed explanation at FINE of why it is ignoring a given request.

  • 0
    Avatar
    Douglas Ferguson

    It would be great to add this info the wiki.

    The examples on the wiki are incorrect and don't indicate that this needs to be a POST

    https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin

  • 0
    Avatar
    Jesse Glick

    POST is not required for this plugin (GET works too), and as far as I know the examples on the wiki are correct.

  • 0
    Avatar
    Douglas Ferguson

    Well.. I kept getting a 4xx until I found this article and changed it to a POST and escaped the & I did not try a get with the escaped &.

    I was also using a text editor to construct the command so I am confident that the only difference from my 2 commands are the POST and the & vs &

  • 0
    Avatar
    Jesse Glick

    Certainly if you are using a Unix shell to run curl, then you need to escape ampersands or otherwise quote the URL. That is not a mistake in the wiki examples, nor anything specific to Jenkins or this plugin, just additional clarification.

Please sign in to leave a comment.