gitpod icon indicating copy to clipboard operation
gitpod copied to clipboard

Project-specific environment variables are no longer available in workspaces

Open najens opened this issue 2 years ago • 11 comments

Bug description

When you setup a new project-specific environment variable and uncheck the "Hide Variable in Workspaces" checkbox to make it available to workspaces, the environment variable is only accessible in prebuild and not accessible in the workspace. This was working a few weeks ago and appears to have stopped working without any changes made on our end. I also tried recreating the environment variable and making visible to workspaces again and that didn't work. There appears to be a regression on the Gitpod side, unless this is deprecated feature.

Steps to reproduce

  1. Create a new project-specific environment variable and uncheck "Hide Variable in Workspaces"
  2. Run a prebuild of the project and echo the environment variable in a "before" start task. You will see the environment variable during the prebuild.
  3. Start a new workspace off of the prebuild. When the "before" start tasks runs again, the environment variable will now have an empty value.

This bug was repeatable across multiple projects, on new projects, and with new environment variables being set using new prebuilds and new workspaces. Screenshot 2023-06-23 at 1 08 20 PM

Workspace affected

salesrabbit-localfpcomm-8dmliwvatmm

Expected behavior

I would expect the environment variable to be available in the workspace with the value that was set in the Gitpod project settings for environment variables.

Example repository

salesrabbit-localfpcomm-8dmliwvatmm

Anything else?

No response

najens avatar Jun 23 '23 20:06 najens

Hey @najens ,

thanks for reporting.

Start a new workspace off of the prebuild. When the "before" start tasks runs again, the environment variable will now have an empty value.

Just to verify: How exactly are you starting that new workspace off a prebuild? Asking because it might lead to different behavior.

geropl avatar Jun 29 '23 08:06 geropl

Also, when starting a regular workspace from a repository, I see all my environment variables are present as expected. But will re-test with prebuilds now. :+1:

Update: Tried, but can't reproduce :thinking:

@najens Are you using GitLab? And possibly a nested project? I don't see how that should affect this behavior, but that would be a new approach for reproducing this... :+1:

geropl avatar Jun 29 '23 08:06 geropl

@geropl We are using Gitlab and mainConfiguration in the .gitpod.yml file to store the steps for setting up the local environment in a separate repository from where all of our code lives. I have triggered new workspaces from within Gitlab as well as from Gitpod UI. In the instances where I have triggered a new workspace from a prebuild, I've been clicking the green New Workspace (with this prebuild) button after the prebuild has completed. Screenshot 2023-06-29 at 2 47 21 PM Screenshot 2023-06-29 at 2 47 35 PM

najens avatar Jun 29 '23 19:06 najens

@geropl - We're also experiencing this issue. We spin up GitPod instances using the built-in integration with GitLab, and starting something this week variables configured at either the project or the user level no longer inject properly into GitPod. Multiple internal projects at my org have reported the same issue.

RicePatrick avatar Jun 30 '23 14:06 RicePatrick

@PatrickRice-KSC Are you using the mainConfiguration feature as well?

geropl avatar Jul 03 '23 19:07 geropl

@geropl - We are not, no 😕

I'm also a maintainer on https://gitlab.com/gitlab-org/terraform-provider-gitlab , which has a gitpod file, and that project works appropriately and properly inherits variables. Maybe something with public vs private repositories?

RicePatrick avatar Jul 05 '23 15:07 RicePatrick

@geropl - Any ideas here, or any additional information we could provide to help troubleshoot? This still seems to be impacted our projects.

RicePatrick avatar Jul 26 '23 14:07 RicePatrick

@geropl This also continues to affect our projects. Every time we create a new workspace, we have to manually set all of the project specific environment variables in the terminal and then manually re-run each of the before and init steps for several tasks that depend on the environment variables in order to get our development services up and running. I'd also be happy to provide any more details that may help troubleshoot.

najens avatar Jul 26 '23 14:07 najens

My issue seems to be resolved for project variables now (not sure what would have resolved it, but figured I'd update the issue). For user variables, the documentation for GitLab has been updated to state that scoping requires "*/**" instead of "*/*", which resolved the user variable issue for everyone.

Just wanted to chime in for anyone else who may find this issue.

RicePatrick avatar Dec 12 '23 01:12 RicePatrick

I have a project in Github, and I see the same things. Setting up project variables ('visible') in Gitpod, but the workspace doesn't receive these variables. A few days (weeks?) ago it still worked. I am not sure what changed?

shaal avatar Dec 21 '23 22:12 shaal

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 22 '24 15:05 github-actions[bot]