Skip to content
Snippets Groups Projects
Commit 1047ed7e authored by Zygmunt Krynicki's avatar Zygmunt Krynicki
Browse files

ci: allow forks to have different names


When the fork of the "docs" repository is called something else, we need to
refer to it by the real name to successfully perform the replacement for merge
request pipelines.

Use some bash and CI_MERGE_REQUEST_SOURCE_PROJECT_PATH to find the bare name of
the project. This works because the variable is re-interpolated by bash during
job execution.

Signed-off-by: default avatarZygmunt Krynicki <zygmunt.krynicki@huawei.com>
parent b400ba6d
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,16 @@ reuse:
# GitLab cache system, and will be reused between pipelines of the same
# project. Note that the .cache directory name is special.
CI_ONIRO_MANIFEST_MIRROR_REPO_DIR: $CI_PROJECT_DIR/.cache/repo-mirror
# XML snippet to inject as a "local manifest" for repo. Those allow arbitrary
# modifications to the project structure to happen before "repo sync" is used
# to construct the workspace.
#
# The default interpreter for the local manifest is plain "echo". For some
# more complex cases, where inline shell is required, use "eval" instead
# and put "cat" echo into the local manifest, coupled with a here-doc
# value.
CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST: ""
CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST_INTERPRETER: echo
# Directory where repo workspace is constructed.
CI_ONIRO_REPO_WORKSPACE_DIR: $CI_PROJECT_DIR/.tmp/repo-workspace
# Use fastest cache compression algorithm, as bulk of the cache is
......@@ -169,7 +179,9 @@ reuse:
- echo "Initializing repository workspace from $CI_ONIRO_MANIFEST_REPO_URL and $CI_ONIRO_MANIFEST_REPO_REV"
- repo init --reference "$CI_ONIRO_MANIFEST_MIRROR_REPO_DIR" --manifest-url "$CI_ONIRO_MANIFEST_REPO_URL" --manifest-branch "$CI_ONIRO_MANIFEST_REPO_REV" --no-clone-bundle
- mkdir -p "${CI_ONIRO_REPO_WORKSPACE_DIR}/.repo/local_manifests"
- test -n "${CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST:-}" && echo "$CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST" | tee "${CI_ONIRO_REPO_WORKSPACE_DIR}/.repo/local_manifests/local.xml"
- set -x
- test -n "${CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST:-}" && "$CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST_INTERPRETER" "$CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST" | tee "${CI_ONIRO_REPO_WORKSPACE_DIR}/.repo/local_manifests/local.xml"
- set +x
- echo "Synchronizing repository workspace"
- repo sync --force-sync
- gl_section_close repo_workspace_setup
......@@ -207,7 +219,9 @@ build-docs:
# thing we can do right now.
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
variables:
CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST: >
CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST_INTERPRETER: eval
CI_ONIRO_REPO_WORKSPACE_LOCAL_MANIFEST: |
cat <<__EOM__
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!-- remove original docs project entry -->
......@@ -215,8 +229,9 @@ build-docs:
<!-- add remote representing the project -->
<remote name="oniro-override" fetch="${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}/../" />
<!-- add docs at the exact version are testing -->
<project name="${CI_PROJECT_NAME}" path="docs" remote="oniro-override" revision="${CI_COMMIT_SHA}" />
<project name="$(basename "$CI_MERGE_REQUEST_SOURCE_PROJECT_PATH")" path="docs" remote="oniro-override" revision="${CI_COMMIT_SHA}" />
</manifest>
__EOM__
# Or when things land.
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment