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

Shared libraries root to be specified in the PATH field

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      2.21

      Description

      Currently the Pipeline Shared Libraries plugin takes the shared libs only from ROOT of the repository like <GIT_ROOT>/vars, <GIT_ROOT>/src etc.

      Please could it be taking PATH which would point to the ROOT of the shared libraries for this plugin? I know that there would be workaround to create second GIT repository just for building stuff but we would like to keep the versioning of sources and the build setup on one place.

      Thanks in advance.

        Attachments

          Issue Links

            Activity

            Hide
            waltermeier Walter Meier added a comment -

            For anyone interested in a workaround. I got a repo to work as a Jenkinsfile repo and as Shared Library, complete with jenkins-pipeline-unit and JUnit5 tests, by using Gradle.

            Here's my build.gradle:

            apply plugin: 'groovy'
            
            group 'com.tieto'
            version '1.0-SNAPSHOT'
            
            sourceCompatibility = 1.8
            
            sourceSets {
                main.groovy.srcDirs = ['src']
                test.groovy.srcDirs = ['test']
                vars.groovy.srcDirs = ['vars']
            }
            
            repositories { mavenCentral() }
            
            String junitVersion = '5.3.1'
            dependencies {
                compile 'org.codehaus.groovy:groovy-all:2.4.12'
                testCompile (
                        "org.junit.jupiter:junit-jupiter-api:$junitVersion",
                        'com.lesfurets:jenkins-pipeline-unit:1.1',
                )
                testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
            }
            
            test {
                useJUnitPlatform()
                testLogging.showStandardStreams = true
            }
            

            And here's how my repo is structured:

            Show
            waltermeier Walter Meier added a comment - For anyone interested in a workaround. I got a repo to work as a Jenkinsfile repo and as Shared Library, complete with jenkins-pipeline-unit and JUnit5 tests, by using Gradle. Here's my build.gradle: apply plugin: 'groovy' group 'com.tieto' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 sourceSets { main.groovy.srcDirs = [ 'src' ] test.groovy.srcDirs = [ 'test' ] vars.groovy.srcDirs = [ 'vars' ] } repositories { mavenCentral() } String junitVersion = '5.3.1' dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.12' testCompile ( "org.junit.jupiter:junit-jupiter-api:$junitVersion" , 'com.lesfurets:jenkins-pipeline-unit:1.1' , ) testRuntimeOnly ( "org.junit.jupiter:junit-jupiter-engine:$junitVersion" ) } test { useJUnitPlatform() testLogging.showStandardStreams = true } And here's how my repo is structured:
            Hide
            mironveryanskiy Miron Veryanskiy added a comment -

            This issue was marked closed in 2016.

            Since the closure of this issue in 2016, it has been heavily requested in the comments.
            Re-opening for reconsideration of the requested feature.

            Show
            mironveryanskiy Miron Veryanskiy added a comment - This issue was marked closed in 2016. Since the closure of this issue in 2016, it has been heavily requested in the comments. Re-opening for reconsideration of the requested feature.
            Hide
            yizhuan Yizhuan Yu added a comment -

            I submitted a fix to this, and have made a pull request (checks passed, pending merge), 

            https://github.com/jenkinsci/workflow-cps-global-lib-plugin/pull/84

            In this attempted fix, I added a "Library base path" (libBasePath) to "Global Pipeline Libraries" configuration, which is a relative path, e.g. common/subprojects/sharedlibs/, that will be added to the library path so that the library will be loaded from "${libBasePath}/src/*/.groovy", "${libBasePath}/vars/.groovy", "${libBasePath}/vars/.txt", "${libBasePath}/resources/". If blank, the library will be loaded from default location under project root of code repository "src/*/.groovy", "vars/.groovy", "vars/.txt", "resources/". 

            Show
            yizhuan Yizhuan Yu added a comment - I submitted a fix to this, and have made a pull request (checks passed, pending merge),  https://github.com/jenkinsci/workflow-cps-global-lib-plugin/pull/84 In this attempted fix, I added a "Library base path" (libBasePath) to "Global Pipeline Libraries" configuration, which is a relative path, e.g. common/subprojects/sharedlibs/, that will be added to the library path so that the library will be loaded from "${libBasePath}/src/* / .groovy", "${libBasePath}/vars/ .groovy", "${libBasePath}/vars/ .txt", "${libBasePath}/resources/". If blank, the library will be loaded from default location under project root of code repository "src/* / .groovy", "vars/ .groovy", "vars/ .txt", "resources/". 
            Hide
            lqbweb Ruben Perez added a comment -

            These sort of issues with shared libraries (like not being able to load one library from the local filesystem in a clean manner) makes me sometimes feel to look for a complete different alternative to Jenkins.

            +1 for this

            Show
            lqbweb Ruben Perez added a comment - These sort of issues with shared libraries (like not being able to load one library from the local filesystem in a clean manner) makes me sometimes feel to look for a complete different alternative to Jenkins. +1 for this
            Hide
            stuff4ben Ben Courliss added a comment -

            Since there's a PR that seems to fix this, can someone take a look at merging it please? Would be very useful to not have to create yet another git repo in my team's already expansive set of repos. I have a "devops" repo already with other devopsy stuff in it. I would love to commit the pipeline shared libraries into that instead of creating a special one just for Jenkins.

            Show
            stuff4ben Ben Courliss added a comment - Since there's a PR that seems to fix this, can someone take a look at merging it please? Would be very useful to not have to create yet another git repo in my team's already expansive set of repos. I have a "devops" repo already with other devopsy stuff in it. I would love to commit the pipeline shared libraries into that instead of creating a special one just for Jenkins.

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              martin_fousek Martin Fousek
              Votes:
              11 Vote for this issue
              Watchers:
              21 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: