JSON variable substitution in CircleCI - circleci

I have appsettings.json file and there are lot of variables like api keys in that file. I would like to know if I can replace them using the circleci environment variables during deployment as per the environment I am deploying it into.

Related

Jenkins Helm Chart - cannot update CASC_JENKINS_CONFIG environment variable

I'm installing Jenkins via their helm charts. I have a values file set up, and also have some JCasC yaml. I wanted to split up the JCasC into multiple files as the contents of the JCasC bloated the values file too much. I was able to split off multiple CasC.yaml files to another folder, and then load them as a config map to the pod, so that is working.
What I'm having a problem with is the environment variable in the container (CASC_JENKINS_CONFIG). If I try to set this via the yaml, I get an error spec.template.spec.containers[0].env[7].name: duplicate name "CASC_JENKINS_CONFIG". The Config as Code plugin allows for multiple locations of config files, so there must be some way to specify multiple locations to this file.
It seems the Jenkins helm chart is overriding this env variable somehow. Is there a way to set it so that the config As Code plugin looks in multiple locations?

Passing arguments to Docker build while deploying AppEngine flex

I'm wondering if it's possible to feed arguments, or environment variables into a Dockerfile used by AppEngine (flex environment).
I'd like to use this command:
COPY ${STAGE}/keycloak-files/realm-config/* /opt/jboss/keycloak/realm-config/
"STAGE" variable would allow to select the origin (I have a "staging" and "production" directory, containing different configurations).
I've got two different app.yml files, one for each environment, but from what I read online, environment variables are not exposed to the Dockerfile at build time.
People suggest to pass arguments to accomplish the task. But how would that be possible with appengine, where we don't execute the docker build command directly?
As #DamPlz said there is not a straight way to pass env variables from the app.yaml to the Dockerfile during the deployment phase . Here are some workarounds that I could think of:
One option could be to create the variable in the Dockerfile directly and if you want to change it each time at runtime you can use a placeholder value and have a script update the value of the variable before running “gcloud app deploy”.
On the other hand you could use build triggers in Google Cloud Registry to modify it in the Docker image using user-defined substitutions.

How to set Global Environment Variables from a file in Jenkins

I am new to Jenkin pardon me for any wrong statements.
I have to set Global Environment Variables from a File(say config or txt) and I want to place that file either in my local or somewhere on the server.
I have gone through some documentations but it all says to use EnvInject Plugin which is basically helps for a specific job when we are building it.
But I want a solution where Global env variables can fetch from the file so that Configure System page can load quickly.
I'm assuming that you are looking to read properties from a specific file and inject them as environment variables to your jenkins job.
You can follow below approach:
Create property file like env.properties with below content:
testvalue='mytest'
Sample code to read the file and inject read variables as environment variables
node`{load "${WORKSPACE}\env.properties"
echo "test value: ${testvalue}"
}

Using Rails credentials within Gitlab CI

I have certain environment variables I need to utilize within Gitlab CI. I need these variables to be within Rails credentials, not stored on the Gitlab runners via settings.
I have been working on this for about a week now and am struggling to find a working solution. The ideal format would be able to use ERB-style markdown (i.e. - <%= Rails.application.credentials[:my_credential] %>) but of course I’m not able to preprocess the ERB and have Gitlab CI still function.
How can I utilize ENV vars on Gitlab CI that cannot be manually stored in the runner?
You can store them in config files on your app. Specifically you can create a ./config.toml file that can be used by the runners. You could then use ERB in the file to access your Rails credentials. You would just need to set up a script that would parse it during the deploy.
Here is an example of one way of doing it. Note that you need to add the .erb to the file extension.

How to use a system environment variable in init.gradle

We are migrating our builds over to gradle and I used to have an external script for deploying that referenced some system environment variables. Am I able to reference them in my init.gradle and how do I access them?
Environment variables are accessed in the usual Java way: System.getenv() to get all of them, and System.getenv("foo") to get a particular one.

Resources