I have a bit of an odd problem that I need an elegant solution to. I am using a build tool that requires logging in to a service (AWS CodeArtifact specifically). When I login via CLI, it sets an environment variable - let's call this TOKEN
. When I run any build, it requires presence of TOKEN
to authenticate.
Now, after logging in, builds in the same shell work but obviously, builds in new shells (which aren't sub-shells) fail because TOKEN
is of course not defined. I'm looking at ways to solve this; ideally a solution that does something like this:
- Login shell: after logging in, save
TOKEN
in~/.token
- All shells: run something every minute which sets
TOKEN
to the value in~/.token
I have 2 questions:
- Is this the best way - or is there something more elegant?
- If so, what's the best way to do (2) above?
The final catch is that this is something I'll be distributing to end users on their machines, so it would be great if its easily scriptable.
Thanks in advance - stay safe!