Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21017

CLI update-job and POSTing config.xml cannot remove properties

    XMLWordPrintable

Details

    Description

      The custom workspace of a Jenkins job cannot be removed by the CLI using update-job.

      Steps to reproduce:
      1. Have a job with a custom workspace.
      2. Remove the custom workspace using the Jenkins java CLI (having a second job without the custom workspace and doing <cli> -get-job <second job> | <cli> update-job <job> is how we encountered this problem).
      3. Note that the config.xml of the job no longer references a custom workspace.
      4. Open the job in the Web GUI. Note that the custom workspace is there, and a save of the job without doing any updates will put the custom workspace configuration back into the config.xml file for the job.

      Bottom line - to remove the custom workspace, one either needs to do it via the web GUI, or do a restart of the Jenkins instance after doing it via the CLI.

      Side note: the " and some other characters are save differently when updating a job via the CLI vs. the Web GUI.

      Example: double quotes " will be changed to '"' in config.xml through CLI method.

      Attachments

        Issue Links

          Activity

            additional-identities plugins has nothing to do with the ticket.
            It's a CLI issue. And a bit of a GUI issue since it's not being updated properly.

            esinsag Sagi Sinai-Glazer added a comment - additional-identities plugins has nothing to do with the ticket. It's a CLI issue. And a bit of a GUI issue since it's not being updated properly.
            jglick Jesse Glick added a comment -

            AbstractItem.updateByXml does not support undefining a field (customWorkspace in this case). I am not even sure how it would be done; XStream does not seem to directly support this.

            jglick Jesse Glick added a comment - AbstractItem.updateByXml does not support undefining a field ( customWorkspace in this case). I am not even sure how it would be done; XStream does not seem to directly support this.
            danielbeck Daniel Beck added a comment -

            Related Cloudbees issue for their Template plugin experiencing the same problem:
            https://rm.cloudbees.com/issues/1346

            danielbeck Daniel Beck added a comment - Related Cloudbees issue for their Template plugin experiencing the same problem: https://rm.cloudbees.com/issues/1346

            The Job DSL plugin is also experiencing this problem: JENKINS-26825

            daspilker Daniel Spilker added a comment - The Job DSL plugin is also experiencing this problem: JENKINS-26825
            jglick Jesse Glick added a comment -

            Some clever soul needs to dig around in XStream internals and make hudson.util.XStream2.unmarshal null out fields when root != null.

            jglick Jesse Glick added a comment - Some clever soul needs to dig around in XStream internals and make hudson.util.XStream2.unmarshal null out fields when root != null .
            jglick Jesse Glick added a comment -

            For CloudBees reference: CJP-1429

            jglick Jesse Glick added a comment - For CloudBees reference: CJP-1429
            abayer Andrew Bayer added a comment -

            So I probably have no idea what I'm talking about and my brain is oozing out my ears from trying to figure this out, but could we do some special-casing in RobustReflectionConverter to specifically grab any JobPropertys (when deserializing a Job descendant) or immediate class fields (for anything descending from AbstractItem) that show up in the deserialization process, and remove any that are set in the original but don't show up in the deserialization?

            abayer Andrew Bayer added a comment - So I probably have no idea what I'm talking about and my brain is oozing out my ears from trying to figure this out, but could we do some special-casing in RobustReflectionConverter to specifically grab any JobPropertys (when deserializing a Job descendant) or immediate class fields (for anything descending from AbstractItem) that show up in the deserialization process, and remove any that are set in the original but don't show up in the deserialization?
            stephenconnolly Stephen Connolly added a comment - - edited
            stephenconnolly Stephen Connolly added a comment - - edited My attempt to fix this: https://github.com/jenkinsci/jenkins/pull/2736

            Code changed in jenkins
            User: Stephen Connolly
            Path:
            core/src/main/java/hudson/util/RobustReflectionConverter.java
            core/src/test/java/hudson/util/XStream2Test.java
            http://jenkins-ci.org/commit/jenkins/c62f4f753d16210b67ec381b9e5d1d60145594d8
            Log:
            JENKINS-21017 When unmarshalling into an existing object, reset missing fields

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stephen Connolly Path: core/src/main/java/hudson/util/RobustReflectionConverter.java core/src/test/java/hudson/util/XStream2Test.java http://jenkins-ci.org/commit/jenkins/c62f4f753d16210b67ec381b9e5d1d60145594d8 Log: JENKINS-21017 When unmarshalling into an existing object, reset missing fields

            Code changed in jenkins
            User: Oleg Nenashev
            Path:
            core/src/main/java/hudson/XmlFile.java
            core/src/main/java/hudson/model/AbstractItem.java
            core/src/main/java/hudson/model/View.java
            core/src/main/java/hudson/util/ReflectionUtils.java
            core/src/main/java/hudson/util/XStream2.java
            core/src/test/java/hudson/util/XStream2Test.java
            test/src/test/java/hudson/model/AbstractProjectTest.java
            test/src/test/java/hudson/model/ViewTest.java
            http://jenkins-ci.org/commit/jenkins/16042bd57bc3e7bc0544b3a4da5e0f79dfa5087b
            Log:
            Merge pull request #3196 from jglick/unmarshal-JENKINS-21017

            JENKINS-21017 When unmarshalling into an existing object, reset missing fields

            Compare: https://github.com/jenkinsci/jenkins/compare/0ac93deba0d1...16042bd57bc3

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: core/src/main/java/hudson/XmlFile.java core/src/main/java/hudson/model/AbstractItem.java core/src/main/java/hudson/model/View.java core/src/main/java/hudson/util/ReflectionUtils.java core/src/main/java/hudson/util/XStream2.java core/src/test/java/hudson/util/XStream2Test.java test/src/test/java/hudson/model/AbstractProjectTest.java test/src/test/java/hudson/model/ViewTest.java http://jenkins-ci.org/commit/jenkins/16042bd57bc3e7bc0544b3a4da5e0f79dfa5087b Log: Merge pull request #3196 from jglick/unmarshal- JENKINS-21017 JENKINS-21017 When unmarshalling into an existing object, reset missing fields Compare: https://github.com/jenkinsci/jenkins/compare/0ac93deba0d1...16042bd57bc3

            People

              jglick Jesse Glick
              royzeng Roy Zeng
              Votes:
              16 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: