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

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

    XMLWordPrintable

    Details

    • Similar Issues:

      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

            royzeng Roy Zeng created issue -
            Hide
            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.

            Show
            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.
            esinsag Sagi Sinai-Glazer made changes -
            Field Original Value New Value
            Component/s cli [ 15624 ]
            Component/s additional-identities [ 17451 ]
            Labels gui jenkins
            jglick Jesse Glick made changes -
            Component/s core [ 15593 ]
            Component/s cli [ 15624 ]
            Labels gui jenkins cli custom-workspace
            Hide
            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.

            Show
            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 made changes -
            Link This issue is duplicated by JENKINS-24657 [ JENKINS-24657 ]
            danielbeck Daniel Beck made changes -
            Affects Version/s current [ 10162 ]
            Environment Red Hat Enterprise Linux Server release 6.4 (Santiago)
            Virtual Machine
            Summary Jenkins CLI update-job misses custom workspace deletion Jenkins CLI update-job and POSTing config.xml cannot remove properties
            Hide
            danielbeck Daniel Beck added a comment -

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

            Show
            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 made changes -
            Link This issue is duplicated by JENKINS-23291 [ JENKINS-23291 ]
            daspilker Daniel Spilker made changes -
            Link This issue is blocking JENKINS-26825 [ JENKINS-26825 ]
            Hide
            daspilker Daniel Spilker added a comment -

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

            Show
            daspilker Daniel Spilker added a comment - The Job DSL plugin is also experiencing this problem: JENKINS-26825
            Hide
            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.

            Show
            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 made changes -
            Remote Link This issue links to "Stack Overflow question (Web Link)" [ 12105 ]
            jglick Jesse Glick made changes -
            Labels cli custom-workspace cli custom-workspace xstream
            jglick Jesse Glick made changes -
            URL http://stackoverflow.com/questions/20668266/xstream-null-out-fields-not-mentioned-in-xml-during-in-place-unmarshal
            Priority Minor [ 4 ] Major [ 3 ]
            Summary Jenkins CLI update-job and POSTing config.xml cannot remove properties CLI update-job and POSTing config.xml cannot remove properties
            daspilker Daniel Spilker made changes -
            Link This issue is blocking JENKINS-30548 [ JENKINS-30548 ]
            Hide
            jglick Jesse Glick added a comment -

            For CloudBees reference: CJP-1429

            Show
            jglick Jesse Glick added a comment - For CloudBees reference: CJP-1429
            Hide
            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?

            Show
            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?
            mjdetullio Matthew DeTullio made changes -
            Link This issue is related to JENKINS-36512 [ JENKINS-36512 ]
            mjdetullio Matthew DeTullio made changes -
            Link This issue is related to JENKINS-36512 [ JENKINS-36512 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 152858 ] JNJira + In-Review [ 178344 ]
            daspilker Daniel Spilker made changes -
            Link This issue is blocking JENKINS-39917 [ JENKINS-39917 ]
            Hide
            stephenconnolly Stephen Connolly added a comment - - edited
            Show
            stephenconnolly Stephen Connolly added a comment - - edited My attempt to fix this: https://github.com/jenkinsci/jenkins/pull/2736
            stephenconnolly Stephen Connolly made changes -
            Remote Link This issue links to "PR#2736 (Web Link)" [ 15389 ]
            stephenconnolly Stephen Connolly made changes -
            Assignee Stephen Connolly [ stephenconnolly ]
            stephenconnolly Stephen Connolly made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            stephenconnolly Stephen Connolly made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            allanlewis Allan Lewis made changes -
            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 &quot; 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 '&quot;' in config.xml through CLI method.
            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.
            daspilker Daniel Spilker made changes -
            Link This issue blocks JENKINS-47528 [ JENKINS-47528 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal OSS-261 (Web Link)" [ 18930 ]
            jglick Jesse Glick made changes -
            Assignee Stephen Connolly [ stephenconnolly ] Jesse Glick [ jglick ]
            jglick Jesse Glick made changes -
            Status In Review [ 10005 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 3196 (Web Link)" [ 19367 ]
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            Hide
            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

            Show
            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
            Hide
            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

            Show
            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
            jglick Jesse Glick made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]

              People

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

                Dates

                Created:
                Updated:
                Resolved: