Skip to content

Commit

Permalink
Fix UPDATED_REPO unbound var error on dev env tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sunnatillo <sunnat.samadov@est.tech>
  • Loading branch information
Sunnatillo committed Apr 24, 2024
1 parent 8e6d943 commit d879c98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 4 additions & 3 deletions jenkins/jobs/dev_env_integration_tests.pipeline
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ def CLEAN_TIMEOUT = 600
def TIMEOUT = 7200

script {
UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git"
echo "Test triggered from ${UPDATED_REPO}"
ci_git_url = "https://github.com/metal3-io/project-infra.git"

if ("${env.REPO_OWNER}" == "metal3-io" && "${env.REPO_NAME}" == "project-infra") {
echo "Checkout https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git branch ${env.PULL_PULL_SHA}"
ci_git_branch = (env.PULL_PULL_SHA) ?: "main"
ci_git_url = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git"
ci_git_base = (env.PULL_BASE_REF) ?: "main"
// Fetch the base branch and the ci_git_branch when running on project-infra PR
refspec = '+refs/heads/' + ci_git_base + ':refs/remotes/origin/' + ci_git_base + ' ' + ci_git_branch
} else {
ci_git_branch = "main"
ci_git_url = "https://github.com/metal3-io/project-infra.git"
refspec = '+refs/heads/*:refs/remotes/origin/*'
}
agent_label="metal3ci-medium-${IMAGE_OS}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,23 @@ else
export EPHEMERAL_CLUSTER="minikube"
fi

# Clone the source repository
git clone "https://github.com/${REPO_ORG}/${REPO_NAME}.git" tested_repo
cd tested_repo
git checkout "${REPO_BRANCH}"
cd ../
# If the target and source repos and branches are identical, don't try to merge
if [[ "${UPDATED_REPO}" != *"${REPO_ORG}/${REPO_NAME}"* ]] ||
[[ "${UPDATED_BRANCH}" != "${REPO_BRANCH}" ]]; then
git config user.email "test@test.test"
git config user.name "Test"
git remote add test "${UPDATED_REPO}"
git fetch test
if [[ -n "${PR_ID:-}" ]]; then
git fetch origin "pull/${PR_ID}/head:${UPDATED_BRANCH}-branch" || true
fi
# Merging the PR with the target branch
git merge "${UPDATED_BRANCH}" || exit
fi

if [[ "${REPO_NAME}" == "metal3-dev-env" ]]; then
# it will already be cloned to tested_repo
Expand Down

0 comments on commit d879c98

Please sign in to comment.