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

Caching lib too soon

    XMLWordPrintable

Details

    Description

      I want to load a specific library and if it fails, load a working library, something like this:

       

      try{
          library("pipeline${params.build_system_branch}")
      } catch(Exception e) {
          library("pipeline")
      } 

      When I run this pipeline, I got this expected exception:

       
      09:40:52 ERROR: Could not resolve i-dont-exist 09:40:52 hudson.plugins.git.GitException: Unknown git object i-dont-exist 09:40:52 at org.jenkinsci.plugins.gitclient.JGitAPIImpl.revParse(JGitAPIImpl.java:2154) 09:40:52 at jenkins.plugins.git.AbstractGitSCMSource$10.run(AbstractGitSCMSource.java:1012) 09:40:52 at jenkins.plugins.git.AbstractGitSCMSource$10.run(AbstractGitSCMSource.java:1006) 09:40:52 at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:398) 09:40:52 at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:340) 09:40:52 at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:1006) 09:40:52 at jenkins.scm.api.SCMSource.fetch(SCMSource.java:636) 09:40:52 at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.lambda$retrieve$0(SCMSourceRetriever.java:75) 09:40:52 at org.jenkinsci.plugins.workflow.libs.SCMBasedRetriever.retrySCMOperation(SCMBasedRetriever.java:222) 09:40:52 at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.retrieve(SCMSourceRetriever.java:75) 09:40:52 at org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:243) 09:40:52 at org.jenkinsci.plugins.workflow.libs.LibraryStep$Execution.run(LibraryStep.java:232) 09:40:52 at org.jenkinsci.plugins.workflow.libs.LibraryStep$Execution.run(LibraryStep.java:160) 09:40:52 at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) 09:40:52 at hudson.security.ACL.impersonate2(ACL.java:451) 09:40:52 at hudson.security.ACL.impersonate(ACL.java:463) 09:40:52 at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) 09:40:52 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) 09:40:52 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 09:40:52 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) 09:40:52 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 09:40:52 at java.base/java.lang.Thread.run(Thread.java:833)
      But just after I got this message:
      09:40:52 [Pipeline] library*09:40:52* Only using first definition of library pipeline
      Thus it makes me assume that the library is cached before it is actually retrieved.

      The workaround I used is to define 2 libraries:

      try {
           library("pipeline${params.build_system_branch}")
      } catch(Exception e) {
           library("pipeline-fallback") 
      }  

      Attachments

        Activity

          People

            Unassigned Unassigned
            odussault Olivier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: