minimal config.xml and strange behavior

32 views
Skip to first unread message

memoe

unread,
Mar 8, 2016, 4:30:10 PM3/8/16
to Jenkins Developers

Because there is no schema or documentation for config.xml (used for createItem API call) I've been trying to figure it out by just using it.  One of the things that I'd like to know is what is the minimum for creating a viable Project in Jenkins?

If I use the UI to create a new project and select "new item" and "Freestyle Project", give it a name and hit OK it creates an empty project.  If I go look at the config.xml for that Project I see what is pretty small XML which seems to reflect what's being shown (like hudson.scm.NullSCM to reflect a SCM of none).  That makes sense.

However, the API allows me to send an empty config.xml to create a Project (I still need to supply a name).  This XML is simply <project></project> and it will create a Project with some values actually set (like SCM to none) and strangely "Restrict where this project can be run".  However, even more strangely, if I go look at the config.xml for this project it will only show the XML that I used to create the project.  It won't show the hudson.scm.NullSCM to reflect a SCM of none or anything else, it will just show <project></project>, that's it.  This concerns me because the config.xml isn't actually reflecting what the UI is showing me for that project.  Should this project have been created?  Shouldn't the config.xml reflect what is being shown in the UI?

thanks!

Michael Neale

unread,
Mar 8, 2016, 4:53:28 PM3/8/16
to Jenkins Developers
It certainly should - but did you change and save any config items in the UI? If not, I expect they are just the defaults of the plugins installed. If you change the label for instance (restrict where it can run) I bet it would have more in it. 

memoe

unread,
Mar 8, 2016, 5:31:43 PM3/8/16
to Jenkins Developers

Well if I go into that project (that I created with empty project through API) and simply hit save on the Configure page of the UI without changing anything.   It will then have the default values that you'd see when creating an empty project using the UI in the config.xml.  Very strange behavior.

Anyway, I'm going to assume that I should start with the config.xml that's created by creating an empty project in the UI. 

Michael Neale

unread,
Mar 8, 2016, 7:39:55 PM3/8/16
to Jenkins Developers
Best to try that I think. Generally I have started with a config close to I want before using that as a basis to automate via the api (a tad clumsy, I know, but it works). 

Daniel Beck

unread,
Mar 9, 2016, 3:37:08 AM3/9/16
to jenkin...@googlegroups.com

On 08.03.2016, at 23:31, memoe <allen...@jpl.nasa.gov> wrote:

> Very strange behavior.

Jenkins generally only modifies configuration files when requested to do so (i.e. someone clicks 'Save'). There's no roundtrip when POSTing a config.xml, it simply gets loaded. It's often the case (e.g. when adding new features) that a default behavior is determined programmatically when loading a configuration file without any related data. Only when saving to disk, this is made explicit (and e.g. the option's value written to the config file). Your empty project config is an extreme case of this.

Note that you'll probably run into JENKINS-21017 when pursuing this further.

Robert Sandell

unread,
Mar 9, 2016, 5:25:12 AM3/9/16
to jenkin...@googlegroups.com
The in-memory data model can be queried via http://jenkins/job/yourjob/api/xml while http://jenkins/job/yourjob/config.xml is the "on-disk" data model.

/B


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/AD189505-9F33-4CB4-B11F-B43A572E90FC%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.
Reply all
Reply to author
Forward
0 new messages