println(ANSI_BOLD + ANSI_GREEN + "First run of the job. Parameters created. Stopping the current build. Please trigger new build and provide parameters" + ANSI_NORMAL)
return
}
if (!params.release_branch.contains('release-') || params.release_branch == '') {
println(ANSI_BOLD + ANSI_RED + "Uh oh! Release branch is not in valid format. Please provide value as release-" + ANSI_NORMAL)
error 'Error: Release branch name format error'
}
if (params.repositories == '') {
print(ANSI_BOLD + ANSI_RED + "Uh oh! No repositories are selected!" + ANSI_NORMAL)
error 'No repositories selected'
}
stage('Get branches') {
cleanWs()
params.repositories.split(',').each { repo ->
dir("$WORKSPACE") {
repo_name = repo.split('/')[1]
sh "git clone --depth 1 --no-single-branch https://github.com/$repo $repo_name"
dir("$repo_name") {
sh "echo $repo_name >> $WORKSPACE/branches.txt"
sh "git branch -a | grep \"remotes/origin/${params.release_branch}\" | cut -d '/' -f3 >> $WORKSPACE/branches.txt"
sh "echo \\\n-------------------------------------------\\\n >> $WORKSPACE/branches.txt"