question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DockerV2: Task ignores addPipelineData and always sets two labels on build

See original GitHub issue

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: DockerV2 https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/DockerV2

Environment

  • Server - Azure Pipelines

  • Agent - Hosted:

    • Image: ubuntu-18.04
    • Pool: Azure Pipelines

Issue Description

[Include task name(s), screenshots and any other relevant details]

By default the Docker Task (build/push/build and push) sets pipeline metadata as labels. This can be deactivated by setting addPipelineData: false in the pipelines.yml definition.

Unfortunately, even after deactivating this explicitly, two labels remain present in the build result. The labels in question are build.sourceversion and teamfoundationcollectionuri. While I don’t have a problem with the former, the name and address of the Project Collection is not something I would like to pass around as public data.

Right now there dont seem to be any way to remove these labels other than executing another docker build via the CLI and overwriting/erasing the unwanted labels.

Pipeline metadata is disabled:

- task: Docker@2
displayName: 'build docker image'
inputs:
  command: build
  Dockerfile: $(workdir)/src/web/Dockerfile
  buildContext: $(workdir)/src/web
  addPipelineData: false

The resulting image metadata contains these two labels:

LABEL com.azure.dev.image.build.sourceversion=....
LABEL com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/.../

The issue is that the pipeline task ignores the value of addPipelineData.

Offending line (for teamfoundationcollectionuri): https://github.com/microsoft/azure-pipelines-tasks/blob/714e68f75c1e56ca699f6514700c5824cd231079/Tasks/Common/docker-common-v2/pipelineutils.ts#L23

The task also sets the build.sourceversion label. This is done in pipelineutils.ts line #31

Task logs

Step 16/17 : LABEL com.azure.dev.image.build.sourceversion=e75b414***************0fdef0388ce7550e
 ---> Running in c557bf5ded0a
Removing intermediate container c557bf5ded0a
 ---> 38ee50360568
Step 17/17 : LABEL com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/<Project_Collection_Name>/

Expected behavior

I expect that the Task respects my choice and disabling pipeline metadata actually disables pipeline metadata.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thesattirajucommented, Dec 2, 2020

I’d be happy to help you out in fixing this bug. You can also use this https://github.com/microsoft/azure-pipelines-tasks/pull/13291 PR for reference.

0reactions
saeedhosseini21commented, Jul 4, 2022

Is there a workaround for this problem? These labels are causing some security concerns.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker@2 - Docker v2 task - Microsoft Learn
Build or push Docker images, login or logout, start or stop containers, or run a Docker command.
Read more >
I am using Azure Devops to build and push my Docker image ...
When using buildAndPush command in Docker task, the arguments are ignored. Since this is a combination of two Docker commands, the arguments ...
Read more >
Additional empty tag when using Docker@2 task
ImageTags contains only 2 tags. Docker@2 invoke params - task: Docker@2 displayName: Build and push an image inputs: containerRegistry: '$(docker.
Read more >
Container Images - Quarkus
Quarkus provides extensions for building (and pushing) container images. ... (essentially by having set quarkus.container-image.build=true and left ...
Read more >
Docker driver - Nomad - HashiCorp Developer
The Docker task driver is used to run Docker based tasks. ... labels - (Optional) A key-value map of labels to set to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found