'How to set local variables in build.sbt when CICD pipeline variables fail

In our build.sbt file we have a number of ENV variables where the credentials necessary for authentication through the CICD settings.

However, on a purely local build, these ENV variables are blank and causing errors. How can I set these ENV variables within sbt without exposing them explicitly?

I have a shell script I can run to generate these variables on local machines. Can I call that shell script in the build.sbt on the condition that the variables below aren't set?

val ARTIFACTORY_URL = System.getenv("ARTIFACTORY_URL")
val ARTIFACTORY_HOST = System.getenv("ARTIFACTORY_HOST")
val ARTIFACTORY_SVC_ACCT_PWD = System.getenv("ARTIFACTORY_SVC_ACCT_PWD")
val ARTIFACTORY_SVC_ACCT = System.getenv("ARTIFACTORY_SVC_ACCT")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source