I am currently setting up jenkins with bitbucket. I have create a new jenkins project as multibranch project.
The JenkinsFile is hosted inside the git repository. How can I force jenkins to generate a shorter branch name than the default one.
E:\jenkins\workspace\reposName-BrancheName-ZKIZ7BNGL6RTDKLQAQ7QR4FKZMOB3DDAVZ564BLWT2BY5ZV652VA
How can I get ride of ZKIZ7BNGL6RTDKLQAQ7QR4FKZMOB3DDAVZ564BLWT2BY5ZV652VA
This is my jenkinsFile
#!/usr/bin/env groovy
env.PATH = env.PATH + ";c:\\Windows\\System32"
def call(String label = null, Closure body) {
node(label) {
String path = pwd()
String branchName = env.BRANCH_NAME
if (branchName) {
path = path.split(Pattern.quote(File.separator))
def workspaceRoot = path[0..<-1].join(File.separator)
def currentWs = path[-1]
String newWorkspace = env.JOB_NAME.replace('/', '-')
newWorkspace = newWorkspace.replace(File.separator, '-')
newWorkspace = newWorkspace.replace('%2f', '-')
newWorkspace = newWorkspace.replace('%2F', '-')
if (currentWs =~ '@') {
newWorkspace = "${newWorkspace}@${currentWs.split('@')[-1]}"
}
path = "${workspaceRoot}${File.separator}${newWorkspace}"
}
ws(path) {
body()
}
}
}
pipeline
{
} // pipeline
Is there a way to force Jenkins to generate a shorter name?
pip
gives really strange errors, which hint at the shebang line not working correctly. – Windflower