microsoft / artifacts-credprovider

The Azure Artifacts Credential Provider enables dotnet, NuGet.exe, and MSBuild to interactively acquire credentials for Azure Artifacts feeds.
MIT License
778 stars 705 forks source link

Version 1.3.0-alpha breaks backwards-compatibility #527

Open Mikaciu opened 3 days ago

Mikaciu commented 3 days ago

Hello,

Without the variable USE_NET8_ARTIFACTS_CREDENTIAL_PROVIDER set to false, using the credprovider for old dotnet versions is likely to fail.

Dotnet 6 image build

Console output (azure pipelines)

##[error]#12 [build 3/6] RUN curl -sSL https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
##[error]#12 0.270 INFO: Creating the nuget plugin directory (i.e. /root/.nuget/plugins). 
##[error]#12 0.272 Downloading from https://github.com/Microsoft/artifacts-credprovider/releases/latest/download/Microsoft.Net8.NuGet.CredentialProvider.tar.gz
##[error]#12 0.611 tar: invalid magic
##[error]#12 0.611 tar: short read
##[error]#12 0.611 tar: plugins/netcore: not found in archive
##[error]#12 ERROR: process "/bin/bash -eo pipefail -c curl -sSL https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash" did not complete successfully: exit code: 1

Docker image

FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine3.16 AS build

# Install Bash
# hadolint ignore=DL3018
RUN set -eu \
    && apk add --no-cache --update bash curl

# Install Credential Provider and set env variables to enable Nuget restore with auth
ARG PAT
ARG NUGET_ENDPOINT="https://pkgs.dev.azure.com/xxx"
ARG \
  USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER="false"

SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
# hadolint ignore=SC2016
RUN curl -sSL https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED=true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS='{"endpointCredentials": [{"endpoint":"'${NUGET_ENDPOINT}'", "password":"'${PAT}'"}]}'

Dotnet 3.1 image build

Console output (azure pipelines)

##[error]#13 [build 3/7] RUN curl -sSL https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
##[error]#13 0.320 INFO: Creating the nuget plugin directory (i.e. /root/.nuget/plugins). 
##[error]#13 0.322 Downloading from https://github.com/Microsoft/artifacts-credprovider/releases/latest/download/Microsoft.Net8.NuGet.CredentialProvider.tar.gz
##[error]#13 0.670 tar: invalid magic
##[error]#13 0.670 tar: short read
##[error]#13 0.671 tar: plugins/netcore: not found in archive
##[error]#13 ERROR: process "/bin/bash -eo pipefail -c curl -sSL https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash" did not complete successfully: exit code: 1
##[error]------
##[error] > [build 3/7] RUN curl -sSL https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash:
##[error]0.320 INFO: Creating the nuget plugin directory (i.e. /root/.nuget/plugins). 
##[error]0.322 Downloading from https://github.com/Microsoft/artifacts-credprovider/releases/latest/download/Microsoft.Net8.NuGet.CredentialProvider.tar.gz
##[error]0.670 tar: invalid magic
##[error]0.670 tar: short read
##[error]0.671 tar: plugins/netcore: not found in archive

Dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.10 AS build

RUN set -eu \
    && apk add --no-cache --update bash~=5.0 curl~=7.66

# Install Credential Provider and set env variables to enable Nuget restore with auth
ARG PAT
ARG NUGET_ENDPOINT="https://pkgs.dev.azure.com/xxx"
ARG USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER="false"

SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
RUN curl -sSL https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS '{"endpointCredentials": [{"endpoint":"'${NUGET_ENDPOINT}'", "password":"'${PAT}'"}]}'

The issue here is that the shortened URL https://aka.ms/install-artifacts-credprovider.sh is pointing to the master branch of this repo, which is currently an alpha version.

Maybe it would be possible to have a separate channel or a separate URL for alpha versions of the cred provider ?

Thanks !

Spawney commented 3 days ago

What was happening for me, when using:

ENV USE_NET6_ARTIFACTS_CREDENTIAL_PROVIDER false

In the dockerfile, is that it was looking for:

https://github.com/Microsoft/artifacts-credprovider/releases/download/v1.2.3/Microsoft.Net8.NuGet.CredentialProvider.tar.gz

Which doesnt exist in 1.2.3 version anymore.

I have had to specify the alpha build using:

ENV AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION=v1.3.0-alpha

cobya commented 2 days ago

Should be resolved when #528 is merged. Sorry for the inconvenience everyone, we have some follow up items from this to make our CI validation better for these install scripts - I'll also bring up the idea of "pre-release" install scripts for folks who want to test changes early.

cobya commented 1 day ago

Please let me know if you're still facing any failures with the changes from #528 or mark the issue as resolved if it's no longer occurring.