In order to solve this I used a simple git checkout instead of using the libraryResource, as follow:
node {
checkout([$class: 'GitSCM', branches: [[name: "$branch_name"]], userRemoteConfigs: [[url: "git@github.com:${your_username}/${your_repo_name}.git"]]])
ls_command_output = sh(script: 'ls -1 resources', returnStdout: true).trim()
list_of_jobs = ls_command_output.split('\n').collect{it.trim().replaceAll(".yaml", "")}
}
In words:
- Checkout to the desired Github repo
- Run a ls command to get all files
- Created a list of files (without the ".yaml" suffix)
If you use a declarative pipeline, you can run the above just before your pipeline and use the list_of_jobs variable inside it.