How to Specify Environment Variables When Using Itamae Execute Resources

Asked 1 years ago, Updated 1 years ago, 90 views

To install the jobber to Ubuntu using Itamae to replace the cron written in go

execute'export GOPATH=$HOME/.go;go get github.com/dshearer/jobber' do
  not_if'test-e~/.go/src/github.com/dshearer/jobber'
end

execute'export GOPATH = $HOME/.go; cd to /.go/src/github.com/dshearer/jobber; git checkout v1.0.3; make'do
  not_if'test-e~/.go/bin/jobber'
end

It actually works like this, but
At least I want to do better at specifying environmental variables.

ENV['GOPATH']='$HOME/.go' will fail if $GOPATH is undefined.

If Chef you could have specified the environment variable by specifying the environment attribute in the execute resource, but it does not seem to be implemented in Itamae.

https://github.com/itamae-kitchen/itamae/wiki/execute-resource

Can I specify it somewhere else?

go itamae

2022-09-30 21:14

1 Answers

The only way to specify GOPATH in go is to set the environment variable.
Take advantage of Itamae's behavior or use the env command together.


2022-09-30 21:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.