Does packagesbuild support environment variable defined in the .pkgproj file? - macos

I am trying to use packagesbuild to create packages in MacOS. I want to use generic template with environment variable so that I don't require to create separate pkgproj file for each app but packagesbuild is not able to recognize the environment variable defined in the template file.
After setting the environment variable in the terminal
export APP_PATH='/Users/sachin/Documents/Test/Client/Example.app'
and then using the same environment variable in example.pkgproj
...
<key>PATH</key>
<string>${APP_PATH}</string>
...
then triggering the command packagesbuild using the projectfile
packagesbuild example.pkgproj
getting below eror
ERROR:
Description:
Unable to copy item at path 'APP_PATH' to
'/private/tmp/S2EyTxCb/502/ExampleClient' because the item could not be
found
http://s.sudre.free.fr/Software/Packages/about.html

Related

gradle pass environment variable by file by console/terminal on macOS

I was running my Acceptance test using IntelliJ
Unfortunately sometimes I get this Exception in IntelliJ executing specific task as this:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'SOME_VARIABLE' in value "classpath:/${SOME_VARIABLE}/acceptance-test.properties"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180)
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210)
at org.springframework.core.env.AbstractEnvironment.resolveRequiredPlaceholders(AbstractEnvironment.java:630)
at org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:461)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:280)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:207)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:175)
... 67 more
But, I would like to execute it using my terminal in macOS.
I know that, I can't to do it passing all variables as this manner!
SPRING_PROFILES_ACTIVE=xyz SPRING_CLOUD_CONFIG_URI=http://config-server EUREKA_SERVICE_URL=http=//eureka-server VAULT_PORT=8200 VAULT_AUTHENTICATION=TOKEN VAULT_TRUST_STORE_PWD=xxxxx VAULT_TRUST_STORE=file:/Users/joseluisbz/blabla.ts gradle app:acceptanceTest --stacktrace
Is it possible passing the same .env file in terminal?
Passing ENV values to gradle test is 2 layered
using ./gradle.properties or ~/.gradle/gradle.properties to setup the basic ENV variables. see https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
in the test { } block setup map of env values using either systemProperties or environment as per your need. see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test

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 get the same file path in the different build version

I have a file in different path between develop and production version, how to keep the same when i want to test them?
// In develop version, file in
~/project/assets/file
// In production version, file in
/service/assets/file
I like using a flag library like alecthomas/kingpin, which allows you to set a parameter like:
env := ""
appk.Flag("env", "Environnement (dev, qual, pprd or prod)").Envar("HOST_ENV").Short('e').Required().EnumVar(&env, "dev", "rct", "pprd", "prod")
Not only will you pass an environment name which is always correct (one of the four values "dev", "rct", "pprd", "prod"), but you can also not pass it directly, and it would still be detected through the system environment variable name "HOST_ENV"
You could also pass/set directly a file path/name.
But the idea remains: you can chose, with this library, between:
a config file
a parameter
an environment variable

Setting environment variable with WiX, losing filename at end of path

I am utilizing the WiX "Environment" element to set an environment variable.
<Environment Action="create" Name="My_Certificates" System="yes" Id="certificate_env" Value="[CERT_XML_PATH]" Permanent="yes" />
CERT_XML_PATH gets set to the following: c:\this\is\my\path\myfile.xml
If that file actually exists, the environment variable is set properly and points to the file.
If that particular file doesn't exist at the time of the install, the environment variable is created and set, but the path is truncated to remove the myfile.xml portion.
This installer is part of a larger suite. It has its own standalone MSI. Installing one of the packages creates this xml file, but not the particular one I'm working on. If the xml file has been created, everything works fine. But if this installer is ran first, it will set the environment variable to
The environment variable "My_Certificates" gets created, but set to:
c:\this\is\my\path\
Instead of:
c:\this\is\my\path\myfile.xml
Troubleshooting:
The install log shows the property being set to the proper location.
MSI (s) (70:80) [15:27:44:988]: PROPERTY CHANGE: Adding CERT_XML_PATH property. Its value is 'c:\this\is\my\path\myfile.xml'.
Then we see the installer doing a WriteEnvironmentStrings a utilizing the proper path, including the xml file.
MSI (s) (70:80) [15:27:50:644]: Executing op: UpdateEnvironmentStrings(Name=My_Certificates,Value=c:\this\is\my\path\myfile.xml,Delimiter=[~],Action=536870914,)
WriteEnvironmentStrings: Name: My_Certificates, Value: c:\this\is\my\path\myfile.xml, Action 536870914
screen shot of system variables showing it not set properly
Any insight into why the file name is being truncated would be greatly appreciated.
Found the issue. There is a custom action in the installer that is also trying to set the Environment Variable. When disabling that custom action, everything works as intended.

Access config variables in buldpack bin/compile using bush

I am creating the heroku deploy button. In app.json there is next config variable:
"env": {
"PUBLISH_APP_DIR": {
"value" : "/src/WebApp"
},
and, as expected, it is available in "Config Variables" section on https://dashboard.heroku.com/new?template=
The question is how I can access it value in buldpack bin/compile script? Bash is used as environment:
#!/usr/bin/env bash
I have checked environment variables using 'printenv', and there is no PUBLISH_APP_DIR. $(PUBLISH_APP_DIR) and $PUBLISH_APP_DIR are empty also
I have finally found in buildpack api documentation, that
The application config vars are passed to the buildpack as an argument (versus set in the environment) so that the buildpack can optionally export none, all or parts of the app config vars available in ENV_DIR when the compile script is run.
The name of the file is the config key and the contents of the file is the config value. The equivalent of config var S3_KEY=8N029N81 is a file with the name S3_KEY and contents 8N029N81.

Resources