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

incorrect "ERROR: Library blah expected to contain at least one of src or vars directories" message

      the message about no vars or src is incorrect.

      it is shown if there is no src directory and there are no groovy files in the vars directory.

      for example create a shared library containing just /vars/README.md and some files in /resources. if you try to load it you will get the error ERROR: Library blah expected to contain at least one of src or vars directories but there is a vars directory.

      As can be seen in the code the error message does not match the check.

      this causes confusion.

      whilst I think the error message could be trivially changed I believe that the failure should be removed completely to allow a library with only resources (and not groovy).

      current workaround for both issues is to create a file /vars/hackyWorkaround.groovy containing the following:

      def call() {
          echo "WHY ARE YOU CALLING THIS FUNCTION!??!"
      }
      

          [JENKINS-62961] incorrect "ERROR: Library blah expected to contain at least one of src or vars directories" message

          Jesse Glick added a comment - - edited

          allow a library with only resources (and not groovy)

          That would make little sense as there would be no way to load the resource.

          Jesse Glick added a comment - - edited allow a library with only resources (and not groovy) That would make little sense as there would be no way to load the resource.

          James Nord added a comment - - edited

          why would the libraryResource step not work here?

          libraryResource should allow loading resources from libraries, if there are no groovy files this should not really matter and could be changed if this was an issue?

          James Nord added a comment - - edited why would the libraryResource step not work here? libraryResource should allow loading resources from libraries, if there are no groovy files this should not really matter and could be changed if this was an issue?

          Jesse Glick added a comment -

          If there are no Groovy sources in the library, what would be running the libraryResource step? I am not following the use case.

          Jesse Glick added a comment - If there are no Groovy sources in the library, what would be running the libraryResource step? I am not following the use case.

          James Nord added a comment -

          the `Jenkinsfile` (or just the pipeline inline definition)

          Rather than having to load a file from a repository or curl or... , a Jenkinsfile could load a shared file from a global library or such forth, for example to write it to disk and invoke as a shared shell step.

          James Nord added a comment - the `Jenkinsfile` (or just the pipeline inline definition) Rather than having to load a file from a repository or curl or... , a Jenkinsfile could load a shared file from a global library or such forth, for example to write it to disk and invoke as a shared shell step.

          Jesse Glick added a comment -

          Currently the libraryResource step does not attempt to verify that it is being invoked from code defined in the same library, but it probably should.

          Jesse Glick added a comment - Currently the libraryResource step does not attempt to verify that it is being invoked from code defined in the same library, but it probably should.

            Unassigned Unassigned
            teilo James Nord
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: