Packer in HCL syntax: How do I use multiple environment variables in packer inline shell commands - packer

In HCL syntax, I am not sure how to pass environment variables to use in the inline shell command (e.g. $MY_VARIABLE). I am exporting variables (e.g. export MY_VARIABLE=some value before running packer.

Related

How to set input from bash script in an interactive shell?

So when I install percona mysql, I get the following.
I am trying to automate sql installation using a bash script but how do I enter into the input using bash script? Enter something > hit enter.
The preferred way of achieving this is using unattended mode by setting the following environment variable before calling apt install:
export DEBIAN_FRONTEND=noninteractive
This will not prompt the user for any input but instead use the default values for everything.
If you want to supply an answer to a configuration question different to the default value, use preseeding DebConf.

How to convert Windows path to UNIX path

I'm writing a GitHub Actions workflow that will run on Linux, Windows, and macOS. To avoid redundancy, I want to use the same steps on all platforms as far as possible. This includes UNIX commands like curl and tar that aren't available in PowerShell, the default shell on Windows. So I'm planning to explicitly set the shell to bash on all platforms.
Which brings up the problem: bash expects UNIX paths in commands, but from the documentation, it seems that all environment variables contain platform-specific paths. So on Windows, all environment variables will contain Windows paths. How can I convert them to UNIX paths for use in bash?
Edit: Clarifications:
The paths I'm talking about are environment variables set by GitHub Actions such as GITHUB_WORKSPACE.
For each step of a job, GitHub Actions allows me to explicitly specify the shell to be used. So running bash on Windows in a one-liner in GitHub Actions and doesn't require any installation.
This question is primarily about best practices in GibHub Actions, not about what is possible using bash scripts. If the only way to convert the path is to use a bash script, then #Yahampath's comment answers my question. But I was hoping the GitHub team had thought of a more elegant solution.

How to automatically generate the modulefile for Intel compilers

Do you know a way to automatically generate the modulefile for Intel compilers without using the env2 script?
Using latest version of Modules (v4.6+), the module command gets a new sub-command called sh-to-mod that translates the environment changes performed by a given script into modulefile commands.
$ module sh-to-mod sh /path/to/foo-1.2/foo-setup.sh arg1
#%Module
prepend-path PATH /path/to/foo-1.2/bin
set-alias foo {foobin -q -l}
setenv FOOENV arg1
The source-sh modulefile Tcl command is also introduced in version 4.6 of Modules to directly translate the environment changes performed by a given script as if it was the content of the modulefile currently being evaluated.
On older version of Modules, a standalone script named createmodule.py is provided to achieve such script to modulefile translation.

Build status jenkins

How can i access jenkins build status at runtime without email-ext plugin?
i want to access build_status using environment variable of jenkins. Or Any other way to access build status variable of jenkins?
The default Jenkins environment variables don't include the build result.
However, you can use the Groovy Postbuild Plugin, which is run under the Jenkins JVM and have access to the current instance of the build.
Then from groovy you can access the build result via manager.build.result. See my answer here for the example usage.
You can use currentBuild.currentResult which is a global variable inside jenkins server to access the current build status. These variables are accessible inside pipelines.
Further you can check all the available global variables inside the server using below url
http://<server>/pipeline-syntax/globals

Is it possible to specify Windows shell to use when specifying hooks in Mercurial?

I am trying to set up a hook on a remote repository (using hgweb) on a Windows IIS server. The issue I have is that the repository is specified as a UNC path in hgweb's config, and the hook executes cmd.exe using a UNC path which cmd.exe does not support.
Is it possible to specify a different shell to run instead?
As far as I know, you can't tell Mercurial to use a different shell on Windows (but I think you can on a Linux host)
Instead, you could have your hook script call out to a different shell and have that shell execute another script or set of commands. It's messy, but unfortunately Windows isn't know for having great scripting support, especially when compared to *nix-based platforms.
Mercurial hooks can be defined two ways,
as a shell hook (external hook)
as a python hook (in process hook)
if you change it to be a python hook, then you would obviously have the full power of python available to do stuff. Of course there is no reason why you can't write a program in any language and execute it from your external hook as cdeszaq suggests