How to load files from resources folder in Shared library without knowing their names (or number)?

后端 未结 2 1603
心在旅途
心在旅途 2020-12-19 11:47

As you know, in Shared libraries in Jenkins, it is possible to load a resource (located in resources folder) by doing:

<         


        
2条回答
  •  再見小時候
    2020-12-19 12:21

    I decided to use the power of shell scripting. Jenkins server and slaves are all on Linux.

    given: I am in a sub-directory, and the resources folder is one directory up.

    String folder = "resources/teamA"
    sh(script: "cp -R ../${folder}/. .")
    
    // Verify files
    def status = steps.sh(script: "diff ../${folder}/ .", returnStatus : true)
    
    if(status.equals(0)) {
        // do that thing you do
    } else {
        error "FAILURE not all files required exist"
    }
    

提交回复
热议问题