Inject secret into text file


I have a Dockerfile in my git project and when creating a container, I want to insert a secret into that dockerfile. (A database password as an environment variable) like this:


other than using sed, is there a cleaner solution (or plugin) that supports this?

You can try prependToFile: Pipeline Utility Steps

Or, read the file with readFile and write it with wiriteFile: Pipeline: Basic Steps

Never inject secrets directly into an image ( that is what a dockerfile creates).
Pass it when running
a container ( e.g. via environment vars:
docker run -e MY_DB_PASSWORD=xxxxxx <image> <cmd>

You can have an enviroment hint in the docker file:

Mmmm, that makes sense :slight_smile:

I would agree with @bpedersen2 for this one. It can be done but it should not be done.