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

            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?
            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
            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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: