Is there a way to assign the output of a step to another environment variable on Bitrise? - bitrise

The Xcode archive step creates this variable: ${BITRISE_DEPLOY_DIR} and read that pilot uses the PILOT_IPA environment variables for the IPA directory.
Is there a way to assign the output (BITRISE_DEPLOY_DIR) to another environment variable (e.g.: $PILOT_IPA)?

You can do that by using envman (https://github.com/bitrise-io/envman) which is part of the bitrise CLI tool stack.
To assign the value of an existing Environment Variable (Step outputs are just regular Environment Variables) you can use a Script step, and specify this as the content:
#!/bin/bash
echo "BITRISE_DEPLOY_DIR: $BITRISE_DEPLOY_DIR"
envman add --key PILOT_IPA --value "$BITRISE_DEPLOY_DIR"
This'll first print the value of the BITRISE_DEPLOY_DIR environment variable, and then with envman add it'll add a new environment item with the key PILOT_IPA and the value of $BITRISE_DEPLOY_DIR.

Related

How to make Gitlab CI not apply variable when the variable is in file

I have created a GitLab pipeline and predefined variable (type file). That file contains a variable ${myVar} that should not has to be applied before some steps of the job.
I found that when I open that file using cat, the ${myVar} disappeared. Looks like it was applied but with an empty string since its content has not yet been generated.
Question: how to tell GitLab CI to ignore variables in the variable file
The issue is fixed. All you need to do is to add one more $ sign before the variable. Hence instead of ${myVar} you need to specify $${myVar} in this case GitLab CI will not apply the variable
As of Gitlab 13.7 you can disable variable expansion for the variable (enabled by default). See:
https://gitlab.nposervices.com/help/ci/variables/index#expand-cicd-variables

How to pass a parameter as an environment variable

How do you pass a parameter as an environment variable?
Step 1: Open up user bash file 'vim ~/.bash_profile', write the environment variable and save the file
export TWLIO_NUMBER=+303....
Step 2: In the application porperties file, store the variable
twlio_number=${TWLIO_NUMBER}
Step 3: Import Value in order to use it
import org.springframework.beans.factory.annotation.Value;
#Value("${twlio_number}")
private String TWILIO_NUMBER;
Also, if I hardcode the value in the application properties file, the code works.
Pass those as Java-Opts. It will work.
How to pass JVM arguments in SpringBOOT
https://www.baeldung.com/spring-boot-command-line-arguments
So I have a system variable in my spring project.
String dataSourceUrl = System.getenv(DEFAULT_CONNECTION);
I am looking for something quick to set the variable in command line.
I found this command work in mac
export DEFAULT_CONNECTION=value (value wrap in single quote to prevent the values being replaced)
You can check by env | grep DEFAULT_CONNECTION
run as usual mvn spring-boot:run

How to Get Environment Value in Config File

Currently, I have an environment variable in my .env file.
MY_NAME_TEST=Testing
How do I pass that variable as part of a path in a config file? I'm trying to get a path similar to below:
base_path('Plugins/Testing/Database/Migrations/')
Notice the "Testing" part of the path in the sample above; I need that name to be different each time.
You're able to retreive the values anywhere in your laravel project by making use of the env function.
env('MY_NAME_TEST'); // returns "Testing"
In your case it would be used like so:
base_path('Plugins/' . env('MY_NAME_TEST') . '/Database/Migrations/'
The second parameter the env function takes is a default value if a value is not already set.

how do I get the value of an environment variable in Applescript?

Specifically, I need to retrieve the value of the current user's HOME variable. But I would prefer that the answers be generically applicable to any environment variable.
system attribute "HOME" retrieves the value of environment variable HOME.
The mechanism works generically:
set envVarName to "SHELL" # sample variable name
system attribute envVarName # returns, e.g., "/bin/bash"

How to load addtional parameter in CMake?

I want to build a project #local dictionary.
And in 'CMakeLists.txt' the project A want to find another library B using 'FIND_PACKAGE' command.
The problem is that library B can be found in system directory while I rebuild it # my local directory, so how can I control that case by inputting a additional parameter when typing 'cmake .'?
You can give specify variable values using CMake's -D command line option.
Note that the variable in question has to be stored in the cache for this to work, as the command line simply sets a cache entry and local variables hide cache variables of the same name.
cmake -DMY_AWESOME_VARIABLE=Foo <path_to_source>
CMakeLists.txt
[...]
# set a default value that will be used if no option is given on the command line
set(MY_AWESOME_VARIABLE "Default value" CACHE STRING "")
# this line will output the current value from cache; so either the default
# value or whatever was given last on the command line
message(${MY_AWESOME_VARIABLE})
# local variables hide cache entry, so the next message will always print "Local"
set(MY_AWESOME_VARIABLE "Local")
message(${MY_AWESOME_VARIABLE})
you could temporarily change the PATH environment variable to only your local bin aud or usr... by running cmake with:
PATH=~/bin:~/usr:~/usr/bin cmake
But then you have to put all the required executables in that/those folders.

Resources