diff --git a/Jenkinsfile b/Jenkinsfile index a274ba4..33c9d78 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,10 +29,15 @@ pipeline { git config user.name "Jenkins Server" git config user.email jenkins@confdroid.com git fetch origin - # Reset the workspace to the exact branch revision that triggered the build. - git checkout -B "$BRANCH_NAME" "origin/$BRANCH_NAME" - # Create an isolated build branch from the triggering branch. - git checkout -B jenkins-build-$BUILD_NUMBER + source_branch="${gitlabSourceBranch:-${BRANCH_NAME:-${GIT_LOCAL_BRANCH:-$GIT_BRANCH}}}" + source_branch="${source_branch#origin/}" + source_branch="${source_branch#refs/heads/}" + if [ -z "$source_branch" ]; then + source_branch="development" + fi + echo "Using source branch: $source_branch" + # Create an isolated build branch from the triggering branch revision. + git checkout -B jenkins-build-$BUILD_NUMBER "origin/$source_branch" # Merge the current master into the build branch before validation. git merge origin/master --no-ff || { echo "Merge conflict detected"; exit 1; } '''