admin管理员组

文章数量:1400375

I have a jenkinsfile in git branch "my-branch" that imports a class.

@Library('my-branch') _
import foo.bar.info.stuff

However sometimes I create copies of the branch for testing e.g my-branch-2 the jenkinsfile will point to the original branch due to the hardcoded branch name.

I tried to fix as so

def branch = scm.branches[0].name.with{ b -> b.substring( (b.startsWith('*/') ? 2 : 0)) }
library("${branch}")
import foo.bar.info.stuff

But this just gets "unable to resolve class". Same happens if I remove the library statement entirely. Is there a way to have it point to the current branch?

本文标签: Is there a way to use a shared library in Jenkins without hardcoding the branch nameStack Overflow