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

Global shared Library with Scripted pipeline keep cache on shared Library version change

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: workflow-job-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.235.5
      Docker container
    • Similar Issues:

      Description

      Context

      Here is our global shared Lib configuration :

       

      Here, code from our shared library, from different versions :

      CppPipeline.groovy - trunk, HEAD revision (SVN)

      def branches = [:] 
      config.targets.each{        
          branches[it] = {                    
              node ( it ){
      
                  properties([
                      buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
                      pipelineTriggers([[$class:"SCMTrigger", scmpoll_spec: 'H 0 * * *']]),
                  ])
                  
                  yeah_do_things(it)
              }
          }
      }

       CppPipeline.groovy - trunk, older revision (SVN)

      def branches = [:] 
      config.targets.each{        
          branches[it] = {                    
              node ( it ){
                  // NOTHING HERE            
                  yeah_do_things(it)
              }
          }
      }

      Issue

      From my branch's Jenkinsfile, if I swtich from recent Shared Lib to an older one, properties are not cleared properly.

       

      Switch from recent Shared Lib

      @Library("cpp-pipeline@trunk") _

      this revision contains 'pipelineTriggers' and 'buildDiscarder' properties

      to older Shared Lib 

      @Library("cpp-pipeline@trunk@5000") _
      

      this revision do not contains any properties

       

      But job's branch config.xml still contains old properties and is not cleared, even after manual build and Pipeline Scan.

      Exceptations

      Job Properties should be cleared if not specified and not using cache from old builds.

      A workaround we use

      To prevent this issue, a tag of Shared Lib have been created as a reference of the old version, with this following hotfix :

      CppPipeline.groovy - old revision tag + hotfix (SVN)

      def branches = [:] 
      config.targets.each{        
          branches[it] = {                    
              node ( it ){
                  // Clear properties to prevent cached propeties
                  properties([])
      
                  yeah_do_things(it)
              }
          }
      }

      this revision gratantee to not contains any properties with properties([]) set to empty array

       

        Attachments

          Activity

          tatayoyoh Rémy Bob created issue -
          tatayoyoh Rémy Bob made changes -
          Field Original Value New Value
          Description h2. Context

          Here is our global shared Lib configuration :

          !image-2020-11-19-17-41-13-944.png|width=947,height=291!

          Here, code from our shared library, from different versions :

          *{color:#403294}CppPipeline.groovy{color} - trunk, HEAD revision (SVN)*

           
          {code:java}
          def branches = [:]
          config.targets.each{
              branches[it] = {
                  node ( it ){

                      properties([
                          buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
                          pipelineTriggers([[$class:"SCMTrigger", scmpoll_spec: 'H 0 * * *']]),
                      ])
                      
                      yeah_do_things(it)
                  }
              }
          }{code}
           

          *{color:#403294}CppPipeline.groovy{color} - trunk, older revision (SVN)*
          {code:java}
          def branches = [:]
          config.targets.each{
              branches[it] = {
                  node ( it ){
                      // NOTHING HERE
                      yeah_do_things(it)
                  }
              }
          }{code}
          h2. Issue

          From my branch's Jenkinsfile, if I swtich from recent Shared Lib to an older one, properties are not cleared properly.

          Switch from recent Shared Lib

           
          {code:java}
          @Library("cpp-pipeline@trunk") _{code}
          {color:#0747a6}_this revision contains '*pipelineTriggers*' and '*buildDiscarder*' properties_{color}

          to older Shared Lib 
          {code:java}
          @Library("cpp-pipeline@trunk@5000") _
          {code}
           

          *{color:#0747a6}_this revision do not contains any properties_{color}*

           

          But job's branch *config.xml* {color:#de350b}still contains old properties and is not cleared{color}, even after manual build and Pipeline Scan.

          !image-2020-11-19-17-54-55-564.png!

          !image-2020-11-19-18-03-23-418.png!
          h2. Exceptations

          {color:#0747a6}{color:#172b4d}Job{color} *Properties*{color} should be cleared if not specified and not using cache from old builds.
          h2. A workaround we use

          To prevent this issue, a tag of Shared Lib have been created as a reference of the old version, with this following hotfix :

          *{color:#403294}CppPipeline.groovy{color} - old revision tag + hotfix (SVN)*
          {code:java}
          def branches = [:]
          config.targets.each{
              branches[it] = {
                  node ( it ){
                      // Clear properties to prevent cached propeties
                      properties([])

                      yeah_do_things(it)
                  }
              }
          }{code}
          _{color:#0747a6}this revision gratantee to not contains any properties with *properties([])* set to empty array{color}_

           
          h2. Context

          Here is our global shared Lib configuration :

          !image-2020-11-19-17-41-13-944.png|width=947,height=291!

           

          Here, code from our shared library, from different versions :

          *{color:#403294}CppPipeline.groovy{color} - trunk, HEAD revision (SVN)*
          {code:java}
          def branches = [:]
          config.targets.each{
              branches[it] = {
                  node ( it ){

                      properties([
                          buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
                          pipelineTriggers([[$class:"SCMTrigger", scmpoll_spec: 'H 0 * * *']]),
                      ])
                      
                      yeah_do_things(it)
                  }
              }
          }{code}
           *{color:#403294}CppPipeline.groovy{color} - trunk, older revision (SVN)*
          {code:java}
          def branches = [:]
          config.targets.each{
              branches[it] = {
                  node ( it ){
                      // NOTHING HERE
                      yeah_do_things(it)
                  }
              }
          }{code}
          h2. Issue

          From my branch's Jenkinsfile, if I swtich from recent Shared Lib to an older one, properties are not cleared properly.

           

          Switch from recent Shared Lib
          {code:java}
          @Library("cpp-pipeline@trunk") _{code}
          {color:#0747a6}_this revision contains '*pipelineTriggers*' and '*buildDiscarder*' properties_{color}

          to older Shared Lib 
          {code:java}
          @Library("cpp-pipeline@trunk@5000") _
          {code}
          *{color:#0747a6}_this revision do not contains any properties_{color}*

           

          But job's branch *config.xml* {color:#de350b}still contains old properties and is not cleared{color}, even after manual build and Pipeline Scan.

          !image-2020-11-19-17-54-55-564.png!

          !image-2020-11-19-18-03-23-418.png!
          h2. Exceptations

          {color:#0747a6}Job{color} *Properties* should be cleared if not specified and not using cache from old builds.
          h2. A workaround we use

          To prevent this issue, a tag of Shared Lib have been created as a reference of the old version, with this following hotfix :
           
           {color:#403294}*CppPipeline.groovy*{color} *- old revision tag + hotfix (SVN)*
          {code:java}
          def branches = [:]
          config.targets.each{
              branches[it] = {
                  node ( it ){
                      // Clear properties to prevent cached propeties
                      properties([])

                      yeah_do_things(it)
                  }
              }
          }{code}
          _{color:#0747a6}this revision gratantee to not contains any properties with *properties([])* set to empty array{color}_

           

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            tatayoyoh Rémy Bob
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: