Storing pipeline script "as-is", in config.xml?

47 views
Skip to first unread message

Michael Hüttermann

unread,
Apr 13, 2017, 9:41:23 AM4/13/17
to Jenkins Users
Hello,

setting up a Jenkins 2 pipeline script, it will be stored with special chars in config.xml. Example:
stage('Setup') 

 Is it possible to force Jenkins to store the snippet as it was insert into the build job, in this example:
 stage('Setup')

 thank you.

 Best regards,
 Michael
 

Baptiste Mathus

unread,
Apr 13, 2017, 10:34:24 AM4/13/17
to jenkins...@googlegroups.com
It's not possible.
Though my gut feelings are in warning mode on this question: do not trying to play with the XML files directly in general. See those as an internal storage format (which they are BTW).

So if you explain a bit more what you're trying to achieve from a user perspective we'll be able to give you more relevant advice hopefully.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/cae49c36-e241-4ef3-a853-a9289afc40cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher Orr

unread,
Apr 13, 2017, 10:36:02 AM4/13/17
to jenkins...@googlegroups.com
Hi,

On Thu, 13 Apr 2017, at 15:41, 'Michael Hüttermann' via Jenkins Users
wrote:
> setting up a Jenkins 2 pipeline script, it will be stored with special
> chars in config.xml. Example:
> stage('Setup')
>
> Is it possible to force Jenkins to store the snippet as it was insert
> into the build job, in this example:
> stage('Setup')

Unlikely, as Jenkins is just doing plain old XML serialisation, and
`'` is the predefined XML entity for the apostrophe character.
You're not likely to get more control over how the XML is serialised.

At least for me, POSTing a config.xml without entities, and then
fetching it again does return the original XML that I POSTed, e.g.
`stage('First') { echo 'hey' }`.

If you need the XML without entities, just run it through your XML
processor of choice, for example:
$ curl -s http://localhost:8080/job/test/config.xml | xmllint --format -

<script>stage('First') { echo 'hey' }</script>


Regards,
Chris
Reply all
Reply to author
Forward
0 new messages