How to pass environment variable to IntelliJ - shell

I'm running Tomcat through IntelliJ.
My app property file has properties that are filled up by an ENV variable (such as credentials)
DB_PASSWORD=${DB_PASSWORD}
I don't store my credentials on git and these credentials are fetch at run time from a vault.
So manually hardcoding these credentials in IntelliJ somewhere is a no go.
Is there a way to pass ENV vars to IntelliJ?
Or have IntelliJ load a var file prior starting tomcat ?
Or have IntelliJ read the ENV vars of the host (OSX shell in this case)?

Run -> Edit configurations -> Environment variables

If you're running Bash, export your environment variables in ~/.bash_profile:
export DB_PASSWORD=*password_here*
Intellij by default runs Bash in non-interactive mode, so it doesn't load ~/.bashrc.

Related

How to enable NetBeans 15 for Mac honour the system environment variables with Gradle builds

I have recently started to use GitHub Packages to distribute our shared libraries internally and have retrospectively changed the Gradle build configuration to use credentials based on system environment variables, rather than hard-coded e.g.
repositories {
mavenLocal() // only use when testing -SNAPSHOT locally
mavenCentral() // third-parties
maven { // our-library
name = "MyLibrary"
url = "https://maven.pkg.github.com/MyCompany/mylibrary"
credentials {
username = project.findProperty("git_username") ?: System.getenv("git_username")
password = project.findProperty("git_token") ?: System.getenv("git_token")
}
}
}
Unfortunately no matter how many environment variables I changed, whether in ~/.zshrc or .zshenv or .bash_profile or /etc/launchd.conf the build was indicating that the credentials were prohibited, or more accurately were resolved as nul.
Each time I changed a config I also ran the appropriate source to ensure it was active, I even resorted to rebooting, just in case.
The environment variable would always show in the terminal confirming the environment variable was always set up correctly, e.g. echo $git_username or printenv yielded the environment variable and expected sensitive token.
After a lot of experimenting and with the help of a colleague we determined that launching NetBeans 15 from the dock wasn't helping, so instead we also added the following line to ~/.zshrc
alias netbeans="/Applications/NetBeans/Apache\ NetBeans\ 15.app/Contents/MacOS/netbeans &"
But now to launch NetBeans I can't use the dock icon, but manually launch the terminal and then type
netbeans
Here's the new lines added to ~/.zshrc
#
# RW - For GitHub Package access
#
export git_username=NotApplicableUsesToken
export git_token=redacted1
export git_publish_username=NotApplicableUsesToken
export git_publish_token=redacted2
#
# RW - So Netbeans launches and honours the environment variables above
#
alias netbeans="/Applications/NetBeans/Apache\ NetBeans\ 15.app/Contents/MacOS/netbeans &"
My question is, why didn't NetBeans when launched from the dock discover the environment variables? How should I configure NetBeans to pickup the environment variables without this workaround?
The Aqua GUI doesn't read any of the shell configuration files, e.g. .bash_profile, .bashrc, .login, .profile, .zprofile, or .zshrc. You were correct to start looking at launchd. Unfortunately /etc/launchd.conf is no longer supported and the file is not read.
Apple's Runtime Configuration Guidelines in the Environment Variables section states:
There are two ways to make environment variables available to an application. The first is to define the variables in a Terminal session and then launch the application from the same session. ...
The second way to associate environment variables with an application is to include the LSEnvironment key in the application’s information property list file. ...
Editing an application's plist doesn't seem like the best idea and your changes may be lost when the application is updated.
There is a third approach.
launchctl has setenv, unsetenv, and getenv sub-commands for managing environment variables. However the environment variables are not persisted across launchd instances.
It seems that a common approach is to create an agent job .plist in ~/Library/LaunchAgents that runs at user login to macOS that will execute launchctl setenv to set the environment variables that should be available to applications launched from the dock. There are discussions at "Set systemwide variable with /etc/launchd.conf does not work in 10.10" and "Environment variables for GUI apps" that point to resources for this approach. You may also want to see Creating Launch Daemons and Agents.
I haven't tested or tried this approach myself.

How to use environment variables in prisma

From this document, Prisma cli try to download binaries from prisma s3. But as my corporate firewall rules this download was blocked, Following this document,I must change source binary file location by using PRISMA_ENGINES_MIRROR variable.
to utilize this variable,I must set environment variables. my build environment is like ElasticBeanstalk,after git push, build will start. from now on,I couldn't configure env variables in build environment. so that I consider to configure and write PRISMA_ENGINES_MIRROR variable to .env files and push them.
Is it possible? and how can I utilize these variable by .env ?
If someone has opinion,please let me know.
Thanks
You can configure environment variables in Elastic BeanStalk by going to
Configuration > Software Configuration > Environment Properties
You can add PRISMA_ENGINES_MIRROR in Environment Properties and it will be picked up by .env

Removing Cypress default proxy settings

I'm having trouble to load the page of my application under test when running Cypress test. After long investigation I figured out that Cypress is using a corporate proxy which is retrieved from my environment variables according to documentation https://docs.cypress.io/guides/references/proxy-configuration.html#View-proxy-settings-in-Cypress
This proxy is no longer active so I remove it from my environment variables but Cypress is still using it even after restarting both cypress and VsCode.
I also tried the following solutions:
clean up Cypress cache folder
uninstall Cypress and install it again
Installing Cypress on a teammate's machine who never had the proxy environment variables configured worked fine.
My question is: Why Cypress is still retrieving the HTTP_PROXY env var which no longer exists ? How to remove this from Cypress settings ?
Thanks a lot for your help.
environment variables are available in cypress through :
1) Approach 1
adding environment variable through terminal or command line as : CYPRESS_
eg : CYPRESS_TEST create variable TEST
you can see all the variables by typing set in cmd and env in shell , search for cypress in that
2)Approach 2:
to environment file or config file:
check if these files has proxy environment variables:
**3) using plugin file **
check the index.js in plugin folder for
config.env
see if you have proxy variable set in any of these location ( Or from tests ) and try to remove it

Jmeter_home environment variable is not defined correctly in Jenkins only ,works fine with cmd prompt

I am trying to integrate jmeter with Jenkins and when I try to execute getting jmeter_home env variable, is not defined correctly. It works perfectly when try to execute through the command prompt.
Tried multiple options of setting jmeter_home in Jenkins config global as ~/.jmeter.
Changing jmeter path in system and through a couple of options but no luck.
The environment variable name is case-sensitive, it needs to be JMETER_HOME
Tilda resolves to $HOME environment variable in shell, it might be the case it isn't set so in that case you might want to use full path or check your OS configuration
In general as per JMETER_HOME variable description
(Optional) May point to your JMeter install dir. If empty
it will be set relativ to this script.
So you don't have to pass it, JMeter will "guess" its home from the jmeter starup script location
Also remember that you can always launch JMeter .jar file directly as:
java -jar /path/to/ApacheJMeter.jar
And last but not the least you may find Continuous Integration 101: How to Run JMeter With Jenkins article useful

Capistrano set configuration environment variables

I'm shocked I haven't been able to find this with googling but I was wondering how to setup a capistrano deploy where the environment variables store the important config variables (api keys, etc). I know how to access them in the code, I just can't get the environment variables setup.
I'm running Ubuntu 12.10 X64 Server and capistrano doesn't seem to be loading my .bashrc file.
Where can I put the environment variables so that they're loaded when any commands are run.
You can set environment variables by creating the ~/.ssh/environment file as follows:
PATH=/opt/bin:/usr/local/bin:/usr/bin:/bin
LANG=C
Note that you should set PermitUserEnvironment to yes in the /etc/ssh/sshd_config and restart the sshd daemon.

Resources