Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use -p ContainerImageTags flag properly in Gitlab CI pipeline with multiple tags #601

Open
SeppPenner opened this issue Oct 16, 2024 · 0 comments

Comments

@SeppPenner
Copy link

I have found https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container?pivots=dotnet-8-0, #311 and #236, but still don't know how I can configure multiple container image tags while using a version environment variable.

Using: Net 8, latest version in Gitlab CI

What works:

$ dotnet publish -c Release --self-contained --no-restore --output publish/ -p ContainerImageTags="${VERSION}" /t:PublishContainer

What doesn't work:

  1. Adding latest at the end:
$ dotnet publish -c Release --self-contained --no-restore --output publish/ -p ContainerImageTags="${VERSION};latest" /t:PublishContainer
MSBUILD : error MSB1006: Property is not valid.
Switch: latest
For switch syntax, type "MSBuild -help"
  1. Adding latest at the front:
$ dotnet publish -c Release --self-contained --no-restore --output publish/ -p ContainerImageTags="latest;${VERSION}" /t:PublishContainer
MSBUILD : error MSB1006: Property is not valid.
Switch: latest
For switch syntax, type "MSBuild -help"
  1. Using double quotes as described in the publish-as-container reference page:
$ dotnet publish -c Release --self-contained --no-restore --output publish/ -p ContainerImageTags='"latest;${VERSION}"' /t:PublishContainer
/usr/share/dotnet/sdk/8.0.403/Containers/build/Microsoft.NET.Build.Containers.targets(113,5): error CONTAINER2010:
Invalid ContainerImageTags provided: ${VERSION}.
ContainerImageTags must be a semicolon-delimited list of valid image tags. Image tags must be alphanumeric, underscore, hyphen, or period.
  1. Using double quotes as described in the publish-as-container reference page (With latest as second parameter):
$ dotnet publish -c Release --self-contained --no-restore --output publish/ -p ContainerImageTags='"${VERSION};latest"' /t:PublishContainer
/usr/share/dotnet/sdk/8.0.403/Containers/build/Microsoft.NET.Build.Containers.targets(113,5): error CONTAINER2010:
Invalid ContainerImageTags provided: ${VERSION}.
ContainerImageTags must be a semicolon-delimited list of valid image tags. Image tags must be alphanumeric, underscore, hyphen, or period.
  1. With a combined environment variable as suggested in some of the other issues:
$ export ContainerImageTags='latest;${VERSION}'
$ dotnet publish -c Release --self-contained --no-restore --output publish/ /t:PublishContainer
/usr/share/dotnet/sdk/8.0.403/Containers/build/Microsoft.NET.Build.Containers.targets(113,5): error CONTAINER2010:
Invalid ContainerImageTags provided: ${VERSION}.
ContainerImageTags must be a semicolon-delimited list of valid image tags. Image tags must be alphanumeric, underscore, hyphen, or period.
  1. With a combined environment variable as suggested in some of the other issues (With latest as second parameter):
$ export ContainerImageTags='${VERSION};latest'
$ dotnet publish -c Release --self-contained --no-restore --output publish/ /t:PublishContainer
/usr/share/dotnet/sdk/8.0.403/Containers/build/Microsoft.NET.Build.Containers.targets(113,5): error CONTAINER2010:
Invalid ContainerImageTags provided: ${VERSION}.
ContainerImageTags must be a semicolon-delimited list of valid image tags. Image tags must be alphanumeric, underscore, hyphen, or period.

I don't want to (and I can't since the version is taken from the Git tags using https://github.com/GitTools/GitVersion) put the tags directly to the project, but I want to always get two tags: Version (e.g. 1.14.2) and latest. Any ideas what else I can test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant