github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/test/groovy/util/ProjectSource.groovy (about)

     1  package util
     2  
     3  import com.lesfurets.jenkins.unit.global.lib.SourceRetriever
     4  
     5  /**
     6   * Retrieves the shared lib sources of the current project which are expected to be
     7   * at the default location "./vars".
     8   */
     9  
    10  class ProjectSource implements SourceRetriever {
    11  
    12      private def sourceDir = new File('.')
    13  
    14      /*
    15       * None of the parameters provided in the signature are used in the use-case of that retriever.
    16       */
    17      List<URL> retrieve(String repository, String branch, String targetPath) {
    18          if (sourceDir.exists()) {
    19              return [sourceDir.toURI().toURL()]
    20          }
    21          throw new IllegalStateException("Directory $sourceDir.path does not exists!")
    22      }
    23  }