I want to access to some environment variables that I set on .bashrc but i cannot get it using System.getenv(), I am using Intellij-idea ultimate on Ubuntu Linux.
On .bashrc i have:
export TWILIO_SMS_SERVICE_SID="XXXXXXXXXX"
export TWILIO_ACCOUNT_SID="XXXXXXXXXX"
export TWILIO_AUTH_TOKEN="XXXXXXXXXX"
Running on command line $ echo $TWILIO_SMS_SERVICE_SID i got the correct value XXXXXXXXXX.
But this System.getenv("TWILIO_SMS_SERVICE_SID") returns null.
When i run this, i got all the environment variables but not the last that i added:
println("Environment variables: ")
System.getenv().forEach { (key, value) -> println("$key: $value") }
Do you know what the causes might be or how to fix it?
p.s: sorry, I have no idea how to do a POC about this, I am open to any suggestion.
Did you start the Java program directly from IntelliJ IDEA? Depending on how you started it, it might not have the environment variables set, as ~/.bashrc might only be evaluated when you start a bash shell. It should work if you start IntelliJ IDEA (or just your Java program) from the bash shell that has the environment variables set.
According to the deespeech documentation to avoid this error related to tensorflow I have to proceed as follows but I don't know how to set an environment variable. Could you explain me the steps to follow? I use ubuntu 18.04.
You can type TF_FORCE_GPU_ALLOW_GROWTH=true in you terminal before running your program.
You can also add export TF_FORCE_GPU_ALLOW_GROWTH=true in ~/.bashrc and it will load automatically when new terminal will open
I have recently formatted my system and installed Ubuntu 16.0.4 and done all necessary setup for running react-native project.But since then every time i restart the system, getting following error,
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I am setting path by using following command,
export JAVA_Home=/home/syamkishore/Downloads/android-studio/jre
If i do so error will be cleared. But if I restart the system again same error occurs.
Can somebody suggest the permanent solution to set the Java path once forever?
Thank You.
Edit the system Path file /etc/profile
sudo gedit /etc/profile
Add following lines in end
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Please see below link. It explains how to set the java path permanently.
How to set the java class path?
I want to let my application know which image version it is running on.
The idea was to pass the Docker image tag into the image as an environment variable. However I don't want to change the version number in both the image line AND in the ENV variable line all the time.
Example:
version: "3"
VERSION=0.2.3
services:
app:
image: myimage:$VERSION
environment:
- APPLICATION_VERSION:$VERSION
Is it possible to declare variables in order to update all values together or is there any other solution available?
You cannot define $VERSION inside the docker-compose.yml.
You have two options for this:
define it in a .env file
send as a command line argument when you run the docker-compose command. e.g. VERSION=0.2.3 docker-compose up -d
I am working to set up a gitlab runner for multiple projects, and we want to be able to set up environment variables for all of the projects. I tried to set global variables in the .bashrc for both the gitlab-runner and root users but it did not recognize them during the CI script. What is the correct location to declare global environment variables?
You can also inject environment variables to your gitlab-runner directly in the commandline, as the gitlab-runner exec docker --help states:
OPTIONS: ..
--env value Custom environment variables injected to build environment [$RUNNER_ENV] ..
Here is a small example how I use it in a script:
Change the declarations as needed:
declare jobname="your_jobname"
declare runnerdir="/path/to/your/repository"
Get the env file into a bash array.
[ -f "$runnerdir/env" ] \
&& declare -a envlines=($(cat "$runnerdir/env"))
declare -a envs=()
for env in "${envlines[#]}"; do
envs+=(--env "$env")
done
And finally pass it to the gitlab-runner.
[ -d "$runnerdir" ] && cd "$runnerdir" \
&& gitlab-runner exec docker "${envs[#]}" $jobname \
&& cd -
You can define environment variables to inject in the runner's config.toml file. See the advanced runner configuration documentation in the [[runners]] section.
There doesn't seem to be a way to specify environment variables in the GitLab UI just for a specific runner.
With GitLab 13.1 (June 2020), you now have:
Instance-level CI/CD variables
GitLab now supports instance-level variables.
With this ability to set global variables, you no longer need to manually enter the same credentials repeatedly for all your projects.
This MVC introduces access to this feature by API, and the next iteration of this feature will provide the ability to configure instance-level variables directly in the UI.
See Documentation and issue.
Consider using an external persistent secret storage service like Vault or Keywhiz
Disclaimer: I am not associated nor used any of the above services
I have added export MY_VAR="FOO" to gitlab-runner's .bashrc, and it works.
echo export MY_VAR=\"FOO\" >> /home/gitlab-runner/.bashrc
Check which type of executor do you use? (shell, kubernetes, docker-ssh, parallels...) I use shell executor.
Check what type of shell does gitlab-runner use? (How to determine the current shell I'm working on) And edit the proper rc file for that.
Check the Gitlab CI Runner user.
I suggest dump all environment variables for further debugging, by add env to the .gitlab-ci.yml's script:
#.gitlab-ci.yml
job:
script: env
Making changes in ~/.bash_profile NOT ~/.bashrc.
See my answer
You can easily setup Variables in the GitLab Settings:
Project-level variables can be added by going to your project's Settings > CI/CD, then finding the section called Variables.
To make sure your variables are only used in
See:
https://docs.gitlab.com/ee/ci/variables/#variables