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

Cannot remove properties from Jenkinsfile for Pipeline from SCM

    XMLWordPrintable

Details

    Description

      In Pipeline Multibranch (and in general for Pipeline from SCM), when removing properties from a Jenkinsfile the properties of the branch job are not updated.

      Example

      1) I create a Jenkinsfile with Triggers:

      properties([pipelineTriggers([[$class: 'TimerTrigger', spec: 'H * * * *']])])
      
      node {
           ...
      }
      

      After branch indexing, the trigger is correctly set for the job

      2) Now I want to remove this trigger. I remove the properties step:

      node {
           ...
      }
      

      I trigger a branch indexing

      Expected result: My job configuration has no trigger
      Actual result: The trigger is still there


      Workaround

      So pipeline updates the properties only if the properties step is set in the Jenkinsfile. There is therefore a workaround.

      In this particular scenario, if I want to get rid of the trigger, I need to update to something like this first:

      properties([pipelineTriggers([])])
      // or also `properties([])`
      
      node {
        ...
      }
      

      Attachments

        Issue Links

          Activity

            allan_burdajewicz Allan BURDAJEWICZ created issue -
            allan_burdajewicz Allan BURDAJEWICZ made changes -
            Field Original Value New Value
            Issue Type New Feature [ 2 ] Bug [ 1 ]
            allan_burdajewicz Allan BURDAJEWICZ made changes -
            Summary Cannot remove properties from Pipeline Multibranch job Cannot remove properties from Jenkins for Pipeline Multibranch
            allan_burdajewicz Allan BURDAJEWICZ made changes -
            Summary Cannot remove properties from Jenkins for Pipeline Multibranch Cannot remove properties from Jenkinsfile for Pipeline Multibranch
            allan_burdajewicz Allan BURDAJEWICZ made changes -
            Description In Pipeline Multibranch, when removing _properties_ from a Jenkinsfile the properties of the branch job are not updated.

            h3. Example

            1) I create a Jenkinsfile with Triggers:

            {code}
            properties([pipelineTriggers([[$class: 'TimerTrigger', spec: 'H * * * *']])])

            node {
                 ...
            }
            {code}

            After branch indexing, the trigger is correctly set for the job

            2) Now I want to remove this trigger. I remove the properties step:

            {code}
            node {
                 ...
            }
            {code}

            I trigger a branch indexing

            +Expected result:+ My job configuration has no trigger
            +Actual result:+ *The trigger is still there*

            ----

            h3. Workaround

            So pipeline updates the properties only if the _properties_ step is set in the Jenkinsfile. There is therefore a workaround.

            In this particular scenario, if I want to get rid of the trigger, I need to update to something like this first:

            {code}
            properties([pipelineTriggers([])])
            // or also `properties([])`

            node {
              ...
            }
            {code}
            In Pipeline Multibranch (and in general for Pipeline from SCM), when removing _properties_ from a Jenkinsfile the properties of the branch job are not updated.

            h3. Example

            1) I create a Jenkinsfile with Triggers:

            {code}
            properties([pipelineTriggers([[$class: 'TimerTrigger', spec: 'H * * * *']])])

            node {
                 ...
            }
            {code}

            After branch indexing, the trigger is correctly set for the job

            2) Now I want to remove this trigger. I remove the properties step:

            {code}
            node {
                 ...
            }
            {code}

            I trigger a branch indexing

            +Expected result:+ My job configuration has no trigger
            +Actual result:+ *The trigger is still there*

            ----

            h3. Workaround

            So pipeline updates the properties only if the _properties_ step is set in the Jenkinsfile. There is therefore a workaround.

            In this particular scenario, if I want to get rid of the trigger, I need to update to something like this first:

            {code}
            properties([pipelineTriggers([])])
            // or also `properties([])`

            node {
              ...
            }
            {code}
            allan_burdajewicz Allan BURDAJEWICZ made changes -
            Summary Cannot remove properties from Jenkinsfile for Pipeline Multibranch Cannot remove properties from Jenkinsfile for Pipeline from SCM
            danielbeck Daniel Beck added a comment -

            Now I want to remove this trigger. I remove the properties step:

            Not how it works. Would also be dangerous for single-branch Pipelines, whose job config would be reset on every execution, or we'd need confusing special casing.

            properties() should do it.

            danielbeck Daniel Beck added a comment - Now I want to remove this trigger. I remove the properties step: Not how it works. Would also be dangerous for single-branch Pipelines, whose job config would be reset on every execution, or we'd need confusing special casing. properties() should do it.
            danielbeck Daniel Beck added a comment -

            AFAIU it's actually pretty straightforward:

            properties(…) sets them (rather than e.g. add/replace). Absence of properties(…) keeps whatever is currently there.

            danielbeck Daniel Beck added a comment - AFAIU it's actually pretty straightforward: properties(…) sets them (rather than e.g. add/replace). Absence of properties(…) keeps whatever is currently there.
            jglick Jesse Glick added a comment -
            properties()
            

            indeed.

            jglick Jesse Glick added a comment - properties() indeed.
            jglick Jesse Glick made changes -
            Resolution Not A Defect [ 7 ]
            Status Open [ 1 ] Resolved [ 5 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-44848 [ JENKINS-44848 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal OSS-1956 (Web Link)" [ 18496 ]

            People

              Unassigned Unassigned
              allan_burdajewicz Allan BURDAJEWICZ
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: