Inject secret into text file

Hi,

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:

ENV MY_DB_PASSWORD “{MySecret}”

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:
ENV MY_DB_PASSWORD

Mmmm, that makes sense :slight_smile:

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