Setting Environment Variables in S2I - s2i

Currently I am attempting to set an environment variable from my S2I assemble file like so
export VARIABLE=some_dynamic_value
When I actually run the container built by my builder, the environment variable does not exist. Is there a way for the builder to set environment variables dynamically?

Yes, it is. You can put it in the .s2i/environment file. Like described here:
https://access.redhat.com/documentation/en-us/openshift_online/3/html/using_images/source-to-image-s2i#dot-net-core-configuration

Related

export a environment variable for terraform does not work?

i am trying to set a environment variable for terraform
using export TF_VAR_instanceType="t2.nano"
my tf file looks something like this:-
resource "aws_instance" "myFirstEc2Instance" {
ami = "ami-0ca285d4c2cda3300"
instance_type = var.instanceType
}
Note there is terraform.tfvars as well as variables.tf files too, i am trying to see how exporting environment variables work in Mac.
It is using value present terraform.tfvars file.
It's because terraform uses TF_VAR as a fallback. So if it finds the variable in terraform.tfvars it'll use the value. If not, then we'll search for other instances and use the last one it finds.
As a fallback for the other ways of defining variables, Terraform searches the environment of its own process for environment variables named TF_VAR_ followed by the name of a declared variable.
Source
if the same variable is assigned multiple values, Terraform uses the last value it finds, overriding any previous values. Note that the same variable cannot be assigned multiple values within a single source.
So this looks like:
Environment variables
The terraform.tfvars file, if present.
The terraform.tfvars.json file, if present.
Any *.auto.tfvars or *.auto.tfvars.json files, processed in lexical order of their filenames.
Any -var and -var-file options on the command line, in the order they are provided. (This includes variables set by a Terraform Cloud workspace.)
Source

How to pass command line arguments into the implementation js file in gauge project?

I am using gauge-js for running puppeteer scripts and I am trying to pass in custom argument from command lines.
while I am running my gauge run spec command to run the test cases I want to pass in any custom argument like gauge run spec --username=test and read that value inside my implementation files.
You cannot pass custom arguments to Gauge. However, you can use environment variables to pass any additional information you need in your implementation files.
For example, you can run gauge as
(on mac/*nix)
username=test gauge run spec
or
(on windows)
set username=test
gauge run specs
and use the environment variable in your implementation file using process.env.username.
You can additionally set the variable in the .property files in the env folder. These get picked up as environment variables as well.

Set OSM config options using API and not the global config file

When reading OSM files using GDAL, the fields that are read are defined in osmconf.ini, and if I want that certain tags don't appear within the other_tags then I need to add them to the attributes value in the corresponding sections.
This works fine, but is not really portable, so my questions is, is there a ways to define the settings saved in osmconf.ini in a portable way per project?
This is possible using the CPLSetConfigOption function, and store the config file in current working directory:
CPLSetConfigOption("OSM_CONFIG_FILE", "osmconf.ini");

Escaping environment variable names in VSTS

In my build configuration I have say MY.VAR variable defined on Variables tab. In VSTS all build variables are automatically available as environment variables accessible in task steps which is pretty nice. The problem is VSTS converts dot characters to underscores so MY.VAR becomes MY_VAR in environments variables. Which is just stupid as I can have any number of dots in my environment variables:
set MY.VAR=my-numeric-value
How to make VSTS to not convert dots to underscores? Any escaping trick? Or, how can I set MY.VAR environment variable so that it's available to every task in my build?
I tried ${env:MY.VAR} = "my-numeric-value" powershell command which works just fine but the variable is not persisted to the subsequent tasks.
There is no way to change that behavior.
You can use VSTS Task Logging Commands to set the variable value so that the value will be available in subsequent tasks.

how can I check the value of the DJANGO_SETTINGS_MODULE environment variable?

echo $DJANGO_SETTINGS_MODULE doesn't return anything, even though from reading the tutorial my understanding is that this environment variable should have been set. Thanks.
The tutorial doesn't say that. It says that when you run manage.py, it takes care of setting that variable within the project's process. It doesn't export it to the base shell - what would be the point?