3

I have a Jenkins job that has a single boolean parameter. The default value of this parameter is false. I remotely build it from an ANT build script (of another job) by POST'ing to the build URL and passing my token and parameter.

curl -X POST 'MY_JENKINS_SERVER/job/JOB_NAME/buildWithParameters?token=12345;REPORTS=true' --user MY_USERNAME:MY_PASS

Note that I have the URL enclosed in single quotes (which should take care of encoding issues) and that the name of the boolean parameter is REPORTS (capitalized in Jenkins and in ANT). Also, I'd like to note that if I use an ampersand (&) to separate the token and my other parameter I get the following error when building: The reference to entity "REPORTS" must end with the ';' delimiter.

No matter what the value of the REPORTS parameter is in the URL string, the parameter is always the default value of false when it goes to build. I changed the default value to true in Jenkins and it is always true regardless of the passed parameter value. Basically, it always uses the default value and ignores the passed parameter value. I've also tried passing no REPORTS parameter and of course it takes the default value.

In my job's build file (the one that I am triggering remotely), I print the parameter as ${env.REPORTS}

I've looked over similar questions on SO, but none of their solutions work for me. I've tried moving the parameters around in the URL and nothing seems to work. Any ideas?

Jeeves
  • 43
  • 1
  • 4
  • Possible duplicate of [The reference to entity "foo" must end with the ';' delimiter](http://stackoverflow.com/questions/6483807/the-reference-to-entity-foo-must-end-with-the-delimiter) – BalusC May 09 '16 at 12:25

1 Answers1

3

Based on this line:

The reference to entity "REPORTS" must end with the ';' delimiter

Instead of &, try &

This is not an issue with Jenkins, but with Ant which is an XML file. Since & is a special character for XML, in order to have a plain value of & anywhere, you need to write it as &

Slav
  • 27,057
  • 11
  • 80
  • 104
  • Thank you. I can't believe it was so simple. But why does it need to be encoded with &? Unless I'm mistaken, the Parametrized Build Documentation [link](https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build) seemed to imply that quoting a URL doesn't necessitate escaping it. – Jeeves Aug 27 '14 at 17:55
  • I've got no idea in your case. For me, straight up `?token=12345&REPORTS=true` worked without any problems, with single and double quotes. But I ***just*** had a problem elsewhere with the **exact** same error message. For me it was including the `&` as a text in XML file (command line execution from ANT), and the solution was `&` – Slav Aug 27 '14 at 18:08
  • Wait a sec... I re-read your question. You are launching the `curl` from ANT script, so your issue was exactly as mine. It's an XML thing, nothing to do with Jenkins. – Slav Aug 27 '14 at 18:11