Does gitpod have a list of environment variables

From cloud9 I am used to being able to access several environment variables, can’t remember exactly what they were but it was something like: $C9USER, $C9PORT, $C9URL etc, etc I think there were about 20 I could use in bash commands or on the command line. Does gitpod have something similar. Presently I wish to make a qrcode of the url but I can’t access the URL for the open port.

[original thread by Jeremy Ellis]

Just found this site https://www.gitpod.io/docs/34_Command_Line_Interface/ which has the URL, and this https://www.gitpod.io/docs/47_Environment_Variables/

But gp url is the url for the gitpod, not the url for the open port. Any idea how to generate the correct url?

Hi Jeremy, the way to get the correct preview URL for any exposed port is to add a parameter to gp url , like so:

$ gp url 8080
https://8080-abcdef-1234567890.ws-eu0.gitpod.io/

There are also a couple env variables that might be relevant (e.g. GITPOD_WORKSPACE_ID). You can find them by running env | grep GITPOD in your workspace.

So here is what I got after running
env | grep GITPOD

GITPOD_TASKS=[{"stuff in .gitpod.yml"}]
GITPOD_GIT_USER_EMAIL=myEmail@gmail.com
USER_ENV_GITPOD_TASKS=[{"stuff in .gitpod.yml"}]
GITPOD_MEMORY=3543
GITPOD_GIT_USER_NAME=My name with spaces
GITPOD_WORKSPACE_URL=https://*.ws-us0.gitpod.io
GITPOD_WSSYNC_APIPORT=44444
GITPOD_WSSYNC_APITOKEN=*
GITPOD_REPO_ROOT=/workspace/my-gitpod-basics
GITPOD_CLI_APITOKEN=**
GITPOD_INTERVAL=30000
GITPOD_WORKSPACE_ID=**
GITPOD_INSTANCE_ID=*
GITPOD_HOST=https://gitpod.io
GITPOD_THEIA_PORT=23000

Couple of questions:
1 I assume there are differences between GITPOD_TASKS and USER_ENV_GITPOD_TASKS ?

Is GITPOD_MEMORY=3543 fixed or can we set ( ask for ) more memory?

Can we set GITPOD_INTERVAL=30000 to be a smaller number?

Thanks @jankeromnes I was looking for GITPOD_REPO_ROOT as my .gitpod.yml files do not fork well since they are hard coded with the repository name.

Great questions! Thanks @jerteach :slight_smile:

  1. So, from my understanding, GITPOD_TASKS is just a copy of your .gitpod.yml tasks (as you said), and it’s consumed by the Theia IDE. A bit more worrying, USER_ENV_GITPOD_TASKS looks like a bug, that we’re now investigating thanks to your question. :slight_smile:

  2. GITPOD_MEMORY=3543 is set to the typical memory consumption we expect from workspace containers (it’s almost always much lower, but we’re being conservative). And you can actually go over it, up to almost 9GB currently, before your container’s OOM-killer wakes up. And this variable in particular is set to control the JVM’s max allowed RAM usage, but I don’t think it’s used for anything else at the moment.

  3. So, you probably guessed that GITPOD_INTERVAL is the interval at which the Theia IDE will send a heartbeat to the Gitpod service, if there was any user activity in the IDE (i.e. no activity for 30 seconds = no heartbeat to the server). It’s not possible to change it yourself, but I also don’t see how this could be useful, or what it would achieve (note: the hearbeat rate is unrelated to the actual timeout, that stops your workspace after no heartbeats have come in for several minutes)

1 Like

Also, I’m happy to take a look at your .gitpod.yml if you like, and suggest improvements if I see any :slight_smile: please just point me to it if you’re interested

I will be working on GITPOD_REPO_ROOT as soon as I understand VNC.

[ajmalhinas]

@jankeromnes I am trying to generalize my gitpod.dockerfile such that it can be used with different git repos. I am able to access GITPOD_REPO_ROOT in gitpod.yml. However, these variables are not available in image building phase. I have following line in gitpod.dockerfile:

echo “include $GITPOD_REPO_ROOT/podConfs/apache/apache.conf” > /etc/apache2/apache2.conf

and expect it to work with any project. Any assistance please.

Yes, they are not there. We’d prefer to allow building the images without special context, i.e. in plain docker as well. Also, the workspace/ folder is a volume so it doesn’t exist on image build. You’ll need to work with the variables without resolving them during docker build.

I have a question, I’m trying to connect SQL to Python and the tutorial used to use cloud9. What information do I use as a User?

I also ran: env | grep GITPOD

GITPOD_GIT_USER_NAME=Alexander Forrest
GITPOD_WORKSPACE_ID=ada56aa5-5072-49e

Hi @asforrest, welcome to the Gitpod community! :tada:

Running gp env will list the git username and workspace ID but running env | grep GITPOD will all Gitpod related env vars.

FYI, you can also add any user environment variables through the Settings page in the dashboard. See also relevant docs. :books:

You can pass environment variables into your workspace.

If you want to install MySQL you can use the corresponding container image, see reference in the blog.