Gere um arquivo para docker run --env-file a partir de um grupo de variáveis do Azure DevOps em uma pipeline clássica de release ou build. A tarefa inclui variáveis secretas sem precisar listar cada nome na definição da pipeline.
Configuração
Vincule o grupo de variáveis ao estágio que executa a tarefa.
No job do agente, habilite Allow scripts to access the OAuth token. A identidade do job precisa de permissão de leitura no grupo.
Adicione Gerar Docker env / Generate Docker env antes da etapa que inicia o container.
Informe o ID do grupo e um caminho absoluto para o arquivo, como /tmp/app.env.
Use esse caminho em docker run --env-file e apague o arquivo depois de iniciar o container.
O arquivo é criado na máquina do agente. Se o Docker roda em outra máquina via SSH, transfira o arquivo de forma segura antes de iniciar o container.
A tarefa falha quando uma variável não está disponível ou contém uma quebra de linha. Ela não imprime os valores no log. Trate o arquivo gerado como sensível e restrinja o acesso a ele.
English
Generate a file for docker run --env-file from an Azure DevOps variable group in a classic release or build pipeline. The task includes secret variables without listing each name in the pipeline definition.
Setup
Link the variable group to the stage that runs the task.
In the agent job, enable Allow scripts to access the OAuth token. The job identity needs read permission on the group.
Add Gerar Docker env / Generate Docker env before the step that starts the container.
Enter the variable group ID and an absolute output path, such as /tmp/app.env.
Use that path in docker run --env-file and delete the file after the container starts.
The file is created on the agent machine. If Docker runs on another machine through SSH, transfer the file securely before starting the container.
The task fails when a variable is unavailable or contains a newline. It does not print values to the pipeline log. Treat the generated file as sensitive and restrict access to it.