Using environment variables
Using environment variables
Configure environment variables to supply values for properties in your team configuration file.
Environment variables in client configuration can be used to store credentials or other sensitive connection data, such as host and port information.
Example use cases
- Working in virtual environments that do not store credentials locally.
- Create an environment variable for Zowe Explorer to use for authentication instead of looking in a local vault.
- Storing an authentication token for APIML.
- Store personal access tokens (PATs), which have longer durations, and can have narrower scope, than the default JSON web tokens.
Configuring environment variables for credentials
One set of credentials
To use only one set of credentials:
-
Use the
ZOWE_OPT_USERandZOWE_OPT_PASSWORDenvironment variables.These environment variables can also be formatted for use in Zowe CLI.
-
Check the Override With Environment Variables setting in Zowe Explorer.
-
Open your
zowe.config.jsonfile and add the environment variable with the$prefix to the corresponding property. For example,$ZOWE_OPT_USERor$ZOWE_OPT_PASSWORD. -
Confirm that the environment variables work by executing a search for data sets, USS files, or jobs.
Multiple sets of credentials
To use multiple sets of credentials:
-
If checked, uncheck the Override With Environment Variables setting in Zowe Explorer.
-
Create your own non-
ZOWE_OPT_environment variables. For example,OTHER_USERandOTHER_PASSWORD.Add your environment variables and values to your local system. In Windows, go to System Properties. In cloud development environments, secret environment variables can be defined when configuring the cloud IDE.
warningTo prevent conflicts, avoid names already in use by Zowe clients. See Configuring Zowe CLI environment variables for a complete list.
-
Open your
zowe.config.jsonfile and add the environment variable with the$prefix to the corresponding property. For example,$OTHER_USERor$OTHER_PASSWORD. -
Confirm that the environment variables work by executing a search for data sets, USS files, or jobs.
A configuration file with environment variables
The following examples include environment variables in a configuration file.
In the nested structure, the zosmf and apiml service profiles are nested within the lpar profile.
- This avoids repeating the
hostandrejectUnauthorizedproperties in both service profiles. - Environment variables are used for multiple credentials in Lines 14-15 and Line 24.
In the flat structure, the zosmf and apiml service profiles are organized sequentially.
- This includes the
hostandrejectUnauthorizedproperties in both service profiles. - Environment variables are used for multiple credentials in Lines 10-11 and Line 23.
- Nested profiles
- Flat profiles
{
"$schema": "./zowe.schema.json",
"profiles": {
"lpar": {
"properties": {
"host": "my.company.com",
"port": 1234,
"rejectUnauthorized": false
},
"profiles": {
"zosmf": {
"type": "zosmf",
"properties": {
"user": "$ZOWE_USER",
"password": "$ZOWE_PASS",
"authOrder": "basic"
},
"apiml": {
"type": "zosmf",
"properties": {
"port": 7554,
"basePath": "ibmzosmf/api/v1",
"tokenType": "apimlAuthenticationToken",
"tokenValue": "$ZOWE_APIML_PAT",
"authOrder": "token, bearer"
}
}
}
}
}
},
"defaults": {
"zosmf": "lpar.zosmf"
},
"autoStore": false
}
{
"$schema": "./zowe.schema.json",
"profiles": {
"zosmf": {
"type": "zosmf",
"properties": {
"host": "my.company.com",
"port": 1234,
"rejectUnauthorized": false,
"user": "$ZOWE_USER",
"password": "$ZOWE_PASS",
"authOrder": "basic"
}
},
"apiml": {
"type": "zosmf",
"properties": {
"host": "my.company.com",
"port": 7554,
"rejectUnauthorized": false,
"basePath": "ibmzosmf/api/v1",
"tokenType": "apimlAuthenticationToken",
"tokenValue": "$ZOWE_APIML_TOKEN",
"authOrder": "token, bearer"
}
}
},
"defaults": {
"zosmf": "zosmf"
},
"autoStore": false
}