GIT_ASKPASS用于获取用户凭据-与分支无关。
这是插件可以使用的变量列表。从这里可以看到,它
GIT_BRANCH为您提供了远程分支,并
GIT_LOCAL_BRANCH为您签出了本地分支。
def branch = checkout(scm).GIT_BRANCHsh "echo 'The name of the branch containing the commit for this build is: ${branch}'"这将打印远程分支名称以及原始前缀(通常是理想的)。但是,如果您希望不带前缀:
def branch = checkout(scm).GIT_BRANCHbranch = branch.substring(branch.indexOf('/') + 1)sh "echo 'The name of the branch containing the commit for this build is: ${branch}'"


