How can I define values from outside my script? - environment-variables

I'd like to pass some variables into my .nsi script. Either from the environment or the command line, how do I do this?
I found a section in the documentation that suggests I can use the syntax $%envVarName% to use environment variables in my script, but this doesn't seem to work, when I have
File "/oname=$pluginsdir\inst.msi" "$%VERSION%-Installer-64bit.msi"
I get the error
File: "$%VERSION%-Installer-64bit.msi" -> no files found.
$VERSION is in my environment.
Is there something I'm doing wrong with trying to read environment variables, or some other way of passing values into my script?

$%VERSION% should work if you used set VERSION=1.2.3.4
Or you can create defines: makensis -DVERSION=1.2.3.4 myscript.nsi and File: "${VERSION}-Installer-64bit.msi"

Related

Jenkins pass variable into groovy script

Hi I need to pass a variable from select into the groovy script and I haven't a clue how to do it in variable bindings, anyone has an idea how to do it?
I tried with:
version=version
version=$version
version=${version}
version="${version}"
If you are going to use ${ ... } Notation you should enclose it double quotes, i.e.:
versionVar = "${version}"
The other think that keeps bothering me is that you are using the same variable name. I haven't tried but I think that using the same name you could are trying to use the same variable.
Where is the 'version' variable came from?
If you are trying to use Environment variables, then you should try like,
version = env.version

How to write Travis env variable to file?

I'm trying to write a custom Travis env variable to a file for a simple proof of concept thing that I need. However, I'm having trouble getting this to work.
How would I define this in the travis yaml file if my variable is called VARIABLE_X ?
Thanks!
One way to do this is using linux commands, something like:
printenv | grep VARIABLE > all_env
However I don't know how Travis handles the environment (take a look at their docs, here) but it might not work as easily due to encryption, but it should work since your apps wouldn't function if they didn't have the same level of access. If such a case occurs, modifying a few parameters (maybe TRAVIS_SECURE_ENV_VARS) is worth looking into.
If you solved the problem in another way, consider sharing with the community.
Write the environment variable as usual (Shell - Write variable contents to a file)
Define the following within script:
- echo "$VARIABLE_X" > example.txt

Inserting timestamp to folder name Jenkins

I want to rename file in Jenkins so that a file name would contain a timestamp. I installed zentimestamp plugin and tried to use it:
SET ts=${BUILD_TIMESTAMP}
ren file_name.zip file_name_%ts%.zip
but what i get is
file_name_${BUILD_TIMESTAMP}.zip
I got Date and Time Pattern in Global Properties set to: yyyyMMddHHmm.
Can someone please explain me how to use BUILD_TIMESTAMP properly?
It looks like your code is from a Microsoft Batch file? If that's the case you'd reference BUILD_TIMESTAMP like this:
ren file_name.zip file_name_%BUILD_TIMESTAMP%.zip
BUILD_TIMESTAMP should be an environment variable if it's being injected correctly by the plugin. How you reference environment variables changes depending on what scripting solution is being used (e.g. batch, bash, ant, gradle, etc).

Viewing exported env vars with elixir

I understand how you set an environment variable using elixir.
export AWS_ACCESS_KEY_ID=your_access_key_id
Okay that works, but what if I'm not confident that I typed everything correct and I want to check what the value is? How can I do this with Elixir?
You could leverage the following function: System.get_env/1.

Preserving environment variables in CMake

I am working on something that requires some header files from a different source tree. For various reasons, I would like to keep these headers outside of my project and reference them during the make process.
I have a CMake build script that generates my makefiles, but I would like to be able to generate makefiles with references to environment variables in them, such that the generated makefile can be run like so:
HEADERS=/somewhere/on/the/filesystem make
Is this possible using CMake? Failing that, is there a way to get what I'm after using CMake only?
This seems to have worked for me:
set(${PROJECT_NAME}_PORT "$(TARGET_SERIAL_PORT)")
It's a real-world example but I hope it gives you an idea. You can assign a string to a variable which will be copied verbatim to the Makefile.
You should look at add_custom_command using the TARGET and PRE_LINK options.
You can use $ENV{VARIABLE} to get the value of an environment variable, but it will only be evaluated during the cmake run and not during the make.
For passing environment variable to make, you can:
CMAKE_POLICY(PUSH)
CMAKE_POLICY(SET CMP0005 NEW)
ADD_DEFINITIONS(-DHEADER=$ENV{HEADER})
CMAKE_POLICY(POP)
Replace HEADER to whatever your variable name.
Setting cmake policy CMP0005 is for cmake to generate correct escape for you.

Categories

Resources