Octopus deploy JSON Variable substitution not working as expected - octopus-deploy

I am new to Octopus Deploy.
In my .net core applicaton appsettings.json, i have the following variable:
{
"protectedResourceMap": []
}
I have a Octopus variable definition for this variable and values is like. Other variables exists which is used here.
["#{ApiPath}"]
But the final output i am getting is an empty array:
{
"protectedResourceMap": [],
}
Can anyone help me with this?
Thanks

What's the name of your variable? Is it "protectedResourceMap"?
Is "protectedResourceMap" in the root of your appsettings.json?
Did you enable the JSON Configuration Variables feature in your deployment step and provide the path to the file?

Related

Referencing github actions environment variables within the env block

I'm trying to create a new workflow file where I create an environment variable and use that variable in the value of some other environment variables, but it's not recognising it.
on:
workflow_dispatch:
env:
dev_environment: "my-environment"
working_dir_classic: "repo/${{ env.dev_environment }}/services/classic-service/"
working_dir_cron: "repo/${{ env.dev_environment }}/services/my-cron-service/"
Can anyone help?
Above is what I have currently, but I'm unsure what needs fixing.

How to pass parameters to sam template with override-parameters with optional parameters

I'd like to create a SAM template.yml containing lambda and several sqs's. I'd like to deploy it with parameters but not populate all the sqs's only some depending on the environment I need to deploy it on. How do I create a template with partial parameters populated?
I found how to do it in CloudFormation:
https://aws.amazon.com/blogs/infrastructure-and-automation/conditionally-launch-aws-cloudformation-resources-based-on-user-input/
And here's how to do it in SAM template:
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy.html
For SAM templates, see these docs also for setting parameter_overrides via a samconfig.toml file:
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
You can specify the location of the config file with the --config-file /path/to/samconfig.toml argument.
Example samconfig.toml file with parameters configured:
version=0.1
[default.global.parameters]
parameter_overrides=[
"TemplateInput1=Value1",
"TemplateInput2=Value2"
]

Use of variables (bash script) in the mail body in jenkins

I currently have the following script:
var = foo
And the configuration of the email (Editable Email Publisher) I have it like this:
configuration Email Publisher
Reading in other questions, someone said that it worked for him using this:
${ENV, var="var"}
However, it does not work for me, can you help me please?
When you run a script that add environment variable the lifetime of this variable is only until the script ends.
You have plugin Environment Injector (was EnvInject Plugin) that using this plugin you can inject variable to all the job life time.
So if you want to add variable in the build section and to use it in the post build section you need to inject the variable.

TeamCity - how to access environment variable in gradle

I have specified environment variable named DIR in my build agent. It is visible in my parameters/environment variables section of my Build Agent properties. I want to access this variable from gradle. I don't know how. I tried many things like:
if (project.hasProperty("teamcity")) {
println teamcity
println teamcity["teamcity.build.properties.file"]
def properties = file(teamcity["teamcity.build.properties.file"])
println properties.DIR
println DIR
println env.DIR
}
My teamcity file looks like:
{teamcity.buildType.id=Taxi5Mobile_BuildDev, build.vcs.number.Taxi5Mobile_Taxi5devVCS=a23e58c8ff92, teamcity.version=8.1.1 (build 29939), teamcity.buildConfName=Build-dev, teamcity.agent.dotnet.agent_url=http://localhost:9090/RPC2, teamcity.build.id=111, agent.ownPort=9090, agent.name=MacAgent, build.number=82, teamcity.runner.properties.file=/Users/surecase/Desktop/buildAgent/temp/buildTmp/teamcity.runner3909938768619827374.properties, teamcity.build.changedFiles.file=/Users/surecase/Desktop/buildAgent/temp/buildTmp/changedFiles8064633368222257261.txt, teamcity.agent.cpuBenchmark=552, teamcity.build.workingDir=/Users/surecase/Desktop/buildAgent/work/88410410f80bbc04/Mobile/Android, agent.home.dir=/Users/surecase/Desktop/buildAgent, teamcity.auth.userId=TeamCityBuildId=111, teamcity.build.checkoutDir=/Users/surecase/Desktop/buildAgent/work/88410410f80bbc04, teamcity.configuration.properties.file=/Users/surecase/Desktop/buildAgent/temp/buildTmp/teamcity.config8874044708331653991.properties, build.vcs.number=a23e58c8ff92, teamcity.tests.recentlyFailedTests.file=/Users/surecase/Desktop/buildAgent/temp/buildTmp/testsToRunFirst6286498944890258669.txt, teamcity.projectName=Taxi5Mobile, agent.work.dir=/Users/surecase/Desktop/buildAgent/work, teamcity.build.tempDir=/Users/surecase/Desktop/buildAgent/temp/buildTmp, build.vcs.number.1=a23e58c8ff92, teamcity.auth.password=8dYVHDftOmXenz9cJjnCyctBrF5NKq7G, java.io.tmpdir=/Users/surecase/Desktop/buildAgent/temp/buildTmp, teamcity.build.properties.file=/Users/surecase/Desktop/buildAgent/temp/buildTmp/teamcity.build174113942945941853.properties, teamcity.agent.dotnet.build_id=111}
There are some files which contains properties but I don't know how to access them.
Any ideas?
Environment variables can be read using the standard Java API:
def dir = System.getenv("DIR")
It might make sense to use a name that's a little less ambiguous than DIR.

Laravel, how to get the environment value?

I know that I can access the environment value using the global $env variable, but is there the right way to get this value?
You're in luck - this was just added in Beta 4 - see here for details
Added App::environment method.
Edit: these are now a number of various ways to get the environment variable as of Laravel 4.1
App::environment()
app()->environment()
app()->env
$GLOBALS['env'] // not recommended - but it is possible
You can also specifically check for if the current environment is set to 'local'
App::isLocal()
app()->isLocal()
...or 'production'
App::isProduction()
app()->isProduction()
You can also specifically check for if the current environment is set to 'testing'
App::runningUnitTests()
app()->runningUnitTests()
You can also use app()->env.
In Laravel 4 and 5, the Laravel official docs suggest using:
$environment = App::environment();
You may also pass arguments to the environment method to check if the
environment matches a given value:
if (App::environment('local'))
{
// The environment is local
}
if (App::environment('local', 'staging'))
{
// The environment is either local OR staging...
}

Resources