Enable accessing GitLab and GitHub App trigger_paramaters in the same job
Achille Mascia
Hi,
I would like to make an orb that can adapt to the VCS host it's used in.
To do so, I would like to be able to pass both pipeline.trigger_parameters.github_app.total_commits_count and pipeline.trigger_parameters.gitlab.total_commits_count in the environment variables of the job in order to get the total_commits_count from GitLab or GitHub as in the screenshot.
However when I put both the variables I get the Unkown variable(s) error for one of them (GitLab's one is unknown if the pipeline is from GitHub and vice versa).
How could I do this?
S
Sebastian Lerner
could you do something like
if [ -z "${pipeline.trigger_parameters.github_app.total_commits_count}" ]; then
ENV_VAR_NAME="<< pipeline.trigger_parameters.github_app.total_commits_count >>"
fi
Achille Mascia
Sebastian Lerner: Hi, thank you for your suggestion, I think you meant to check if the variable for gitlab was empty. Unfortunately I tried a lot of different options with conditions but I always end up having the Unknown variable(s) error whenever I include both params (Gitlab and GitHub) in the script
S
Sebastian Lerner
Achille Mascia: you're right, sorry about that i forgot how this worked. this is actually unfortunately expected behavior at this time.
We don't have a solution for this at this time, but one thing we are working on is a common set of pipeline values/parameters for all VCS types so that it would just be something like: pipeline.vcs.total_commits_count that would work for any VCS that we support.
I'll update this post when this is live, but for now I don't have a workaround unfortunately.