diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 88d32e70a1d..a2d19f76ba3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,6 +6,8 @@ trigger: branches: include: - '*' + exclude: + - 'release' pr: branches: @@ -205,6 +207,11 @@ jobs: TargetPath: '$(Build.ArtifactStagingDirectory)/metadata' artifactName: metadata + - task: PipAuthenticate@1 + condition: eq(variables['Build.SourceBranch'], 'refs/heads/release') + displayName: 'Pip Authenticate' + inputs: + artifactFeeds: $(AZURE_ARTIFACTS_FEEDS) - script: | set ARCH=$(Platform) @@ -244,6 +251,11 @@ jobs: TargetPath: '$(Build.ArtifactStagingDirectory)/metadata' artifactName: metadata + - task: PipAuthenticate@1 + condition: eq(variables['Build.SourceBranch'], 'refs/heads/release') + displayName: 'Pip Authenticate' + inputs: + artifactFeeds: $(AZURE_ARTIFACTS_FEEDS) - script: | set ARCH=$(Platform) @@ -429,6 +441,11 @@ jobs: inputs: versionSpec: 3.11 + - task: PipAuthenticate@1 + condition: eq(variables['Build.SourceBranch'], 'refs/heads/release') + displayName: 'Pip Authenticate' + inputs: + artifactFeeds: $(AZURE_ARTIFACTS_FEEDS) - script: | if [[ "$(Build.Reason)" == "PullRequest" ]]; then @@ -719,6 +736,12 @@ jobs: - bash: ./scripts/ci/install_docker.sh displayName: Install Docker + - task: PipAuthenticate@1 + condition: eq(variables['Build.SourceBranch'], 'refs/heads/release') + displayName: 'Pip Authenticate' + inputs: + artifactFeeds: $(AZURE_ARTIFACTS_FEEDS) + - task: Bash@3 displayName: 'Build Rpm Package: Azure Linux' inputs: @@ -809,6 +832,11 @@ jobs: steps: - bash: ./scripts/ci/install_docker.sh displayName: Install Docker + - task: PipAuthenticate@1 + condition: eq(variables['Build.SourceBranch'], 'refs/heads/release') + displayName: 'Pip Authenticate' + inputs: + artifactFeeds: $(AZURE_ARTIFACTS_FEEDS) - task: Bash@3 displayName: 'Build Rpm Package' inputs: @@ -926,6 +954,11 @@ jobs: steps: - bash: ./scripts/ci/install_docker.sh displayName: Install Docker + - task: PipAuthenticate@1 + condition: eq(variables['Build.SourceBranch'], 'refs/heads/release') + displayName: 'Pip Authenticate' + inputs: + artifactFeeds: $(AZURE_ARTIFACTS_FEEDS) - task: Bash@3 displayName: 'Build $(deb_system) $(distro) $(arch) Package' inputs: diff --git a/scripts/release/debian/pipeline.sh b/scripts/release/debian/pipeline.sh index 7ac2903299c..23497128092 100755 --- a/scripts/release/debian/pipeline.sh +++ b/scripts/release/debian/pipeline.sh @@ -17,5 +17,6 @@ docker run --rm \ -e CLI_VERSION=$CLI_VERSION \ -e CLI_VERSION_REVISION=1~$DISTRO \ -e DEBIAN_FRONTEND=noninteractive \ + -e PIP_INDEX_URL=$PIP_INDEX_URL \ $DISTRO_BASE_IMAGE \ /mnt/repo/scripts/release/debian/build.sh diff --git a/scripts/release/rpm/azurelinux.dockerfile b/scripts/release/rpm/azurelinux.dockerfile index 4ee528ea955..909d292df5d 100644 --- a/scripts/release/rpm/azurelinux.dockerfile +++ b/scripts/release/rpm/azurelinux.dockerfile @@ -22,7 +22,8 @@ COPY . . # Azure Linux 3's python3 is 3.12, the rpm paths are # /usr/src/azl/RPMS/x86_64/azure-cli-2.63.0-1.azl3.x86_64.rpm # /usr/src/azl/RPMS/aarch64/azure-cli-2.63.0-1.azl3.aarch64.rpm -RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ +RUN --mount=type=secret,id=PIP_INDEX_URL export PIP_INDEX_URL=$(cat /run/secrets/PIP_INDEX_URL) && \ + dos2unix ./scripts/release/rpm/azure-cli.spec && \ REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python3 PYTHON_CMD=python3 \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /usr/src/*/RPMS/*/azure-cli-${cli_version}-1.*.rpm /azure-cli-dev.rpm && \ diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index 52c99a6193c..f5af48f7757 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -15,12 +15,16 @@ set -exv CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` +# PIP_INDEX_URL env must exist in `docker build --secret`, use an empty string if it doesn't exist. +export PIP_INDEX_URL=${PIP_INDEX_URL} + # Create a container image that includes the source code and a built RPM using this file. docker build \ --target build-env \ --build-arg cli_version=${CLI_VERSION} \ --build-arg image=${IMAGE} \ --build-arg python_package=${PYTHON_PACKAGE} \ + --secret id=PIP_INDEX_URL \ -f ./scripts/release/rpm/${DOCKERFILE}.dockerfile \ -t azure/azure-cli:${DOCKERFILE}-builder \ . diff --git a/scripts/release/rpm/pipeline_azurelinux.sh b/scripts/release/rpm/pipeline_azurelinux.sh index 8a89780d0e8..bd9f7440571 100644 --- a/scripts/release/rpm/pipeline_azurelinux.sh +++ b/scripts/release/rpm/pipeline_azurelinux.sh @@ -11,11 +11,15 @@ set -exv CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` +# PIP_INDEX_URL env must exist in `docker build --secret`, use an empty string if it doesn't exist. +export PIP_INDEX_URL=${PIP_INDEX_URL} + # Create a container image that includes the source code and a built RPM using this file. docker build \ --target build-env \ --build-arg cli_version=${CLI_VERSION} \ --build-arg image=${IMAGE} \ + --secret id=PIP_INDEX_URL \ -f ./scripts/release/rpm/azurelinux.dockerfile \ -t azure/azure-cli:azurelinux-builder \ . diff --git a/scripts/release/rpm/ubi.dockerfile b/scripts/release/rpm/ubi.dockerfile index 558d0e85e2e..6a5de643b94 100644 --- a/scripts/release/rpm/ubi.dockerfile +++ b/scripts/release/rpm/ubi.dockerfile @@ -16,7 +16,8 @@ COPY . . # RHEL 8's 'python3' is Python 3.6. RHEL 9's 'python3' is Python 3.9. # We have to explicitly specify 'python39' to install Python 3.9. -RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ +RUN --mount=type=secret,id=PIP_INDEX_URL export PIP_INDEX_URL=$(cat /run/secrets/PIP_INDEX_URL) && \ + dos2unix ./scripts/release/rpm/azure-cli.spec && \ REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=python3.9 \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/*/azure-cli-${cli_version}-1.*.rpm /azure-cli-dev.rpm && \