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

AbstractProject.removeTrigger raises UnsupportedOperationException

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None

      This commit (https://github.com/jenkinsci/jenkins/commit/7facc7733c7040536d4074a2c5805b75ee1d8f35#core/src/main/java/hudson/model/AbstractProject.java) makes AbstractProject.removeTrigger and AbstractProject.removeTrigger fail because the old Vector is DescribableList now. "removeTrigger" uses remove(int) and I think it shouldn't do it.

      java.lang.UnsupportedOperationException
      at java.util.AbstractList.remove(AbstractList.java:161)
      at hudson.model.AbstractProject.removeFromList(AbstractProject.java:1646)
      at hudson.model.AbstractProject.removeTrigger(AbstractProject.java:1622)

          [JENKINS-18813] AbstractProject.removeTrigger raises UnsupportedOperationException

          This is quite a frustrating issue. We have all our SCM polling set up to do

          */5 * * * *

          but jenkins suggests it would be wiser to change it to

          H/5 * * * *

          Since this is in ALL our jobs, we wrote a groovy script to change the config based on example provided here:
          https://wiki.jenkins-ci.org/display/JENKINS/Change+SCMTrigger+for+each+project+to+disable+during+the+night+and+the+week-end

          But impossible to do as removeTrigger fails.
          We have 100s of jobs across multiple jenkins instances. Not really practical to change the polling on each one manually.

          Nathan McDonald added a comment - This is quite a frustrating issue. We have all our SCM polling set up to do */5 * * * * but jenkins suggests it would be wiser to change it to H/5 * * * * Since this is in ALL our jobs, we wrote a groovy script to change the config based on example provided here: https://wiki.jenkins-ci.org/display/JENKINS/Change+SCMTrigger+for+each+project+to+disable+during+the+night+and+the+week-end But impossible to do as removeTrigger fails. We have 100s of jobs across multiple jenkins instances. Not really practical to change the polling on each one manually.

          Pull request to address issue:
          https://github.com/jenkinsci/jenkins/pull/880

          This just ensures the add and remote trigger methods only use Iterator#remove and Collection#add, as these are supported by DescribableList. This seemed a smaller change then adding index support to DescribableList.

          Nathan McDonald added a comment - Pull request to address issue: https://github.com/jenkinsci/jenkins/pull/880 This just ensures the add and remote trigger methods only use Iterator#remove and Collection#add, as these are supported by DescribableList. This seemed a smaller change then adding index support to DescribableList.

          Code changed in jenkins
          User: mcdonan
          Path:
          core/src/main/java/hudson/model/AbstractProject.java
          test/src/test/groovy/hudson/model/AbstractProjectTest.groovy
          http://jenkins-ci.org/commit/jenkins/edf932be37ffdad965c3fcaf6c7d7a6f1efc54f8
          Log:
          [FIXED JENKINS-18813] Add/RemoveTrigger now works

          Ensure the addTrigger and removeTrigger methods only use methods that are
          supported by DescribableList. This means no indexed operations are
          supported, so use only Iterator#remove and Collection#add

          Add Integration Tests to ensure methods work as expected

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: mcdonan Path: core/src/main/java/hudson/model/AbstractProject.java test/src/test/groovy/hudson/model/AbstractProjectTest.groovy http://jenkins-ci.org/commit/jenkins/edf932be37ffdad965c3fcaf6c7d7a6f1efc54f8 Log: [FIXED JENKINS-18813] Add/RemoveTrigger now works Ensure the addTrigger and removeTrigger methods only use methods that are supported by DescribableList. This means no indexed operations are supported, so use only Iterator#remove and Collection#add Add Integration Tests to ensure methods work as expected

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          core/src/main/java/hudson/model/AbstractProject.java
          test/src/test/groovy/hudson/model/AbstractProjectTest.groovy
          http://jenkins-ci.org/commit/jenkins/ba432da2b55383152d6c30bc1ad5ef829d75fa27
          Log:
          Merge pull request #880 from evilmilo/master

          [FIXED JENKINS-18813] Add/RemoveTrigger now works

          Compare: https://github.com/jenkinsci/jenkins/compare/016baea4f096...ba432da2b553

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: core/src/main/java/hudson/model/AbstractProject.java test/src/test/groovy/hudson/model/AbstractProjectTest.groovy http://jenkins-ci.org/commit/jenkins/ba432da2b55383152d6c30bc1ad5ef829d75fa27 Log: Merge pull request #880 from evilmilo/master [FIXED JENKINS-18813] Add/RemoveTrigger now works Compare: https://github.com/jenkinsci/jenkins/compare/016baea4f096...ba432da2b553

          dogfood added a comment -

          Integrated in jenkins_main_trunk #2758

          Result = SUCCESS

          dogfood added a comment - Integrated in jenkins_main_trunk #2758 Result = SUCCESS

          Is it possible to backport this issue fix to LTS releases please? Configuration plugin is not working due to that: https://issues.jenkins-ci.org/browse/JENKINS-19051

          Thank you in advance!

          Vitalii Tiutiunnyk added a comment - Is it possible to backport this issue fix to LTS releases please? Configuration plugin is not working due to that: https://issues.jenkins-ci.org/browse/JENKINS-19051 Thank you in advance!

            Unassigned Unassigned
            dmatag dmatag
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: