Skip to content

Commit f51db41

Browse files
authored
PMC migration to vNext (#403)
* PMC migration * only try one repo * Update * Upgrade pyOpenSSL * debug * use cli to get key vault certificate * update * continue using keyvautl task * typo * Enable other deb distro/release * Enable for the rhel8-amd64 * Enable other rpm distro/release
1 parent d2a1082 commit f51db41

File tree

1 file changed

+64
-42
lines changed

1 file changed

+64
-42
lines changed

azure-pipelines.yml

+64-42
Original file line numberDiff line numberDiff line change
@@ -437,30 +437,32 @@ stages:
437437
# REPO_ID: 5d16326637164fbc1139c4e1
438438
# REPO_DISTRO: ubuntu
439439
# REPO_RELEASE: bionic
440+
440441
ubuntu-focal-amd64:
441442
TYPE: deb
442443
ARCH: amd64
443-
REPO_ID: 5e852952e45fffa1beda61fe
444+
REPO_ID: repositories-deb-apt-50a94aad-3f2d-414c-8792-c8914a994b60
444445
REPO_DISTRO: ubuntu
445446
REPO_RELEASE: focal
446447
ubuntu-focal-arm64:
447448
TYPE: deb
448449
ARCH: arm64
449-
REPO_ID: 5e852952e45fffa1beda61fe
450+
REPO_ID: repositories-deb-apt-50a94aad-3f2d-414c-8792-c8914a994b60
450451
REPO_DISTRO: ubuntu
451452
REPO_RELEASE: focal
452453
ubuntu-jammy-amd64:
453454
TYPE: deb
454455
ARCH: amd64
455-
REPO_ID: 61faea6cea3a770ab120ac8a
456+
REPO_ID: repositories-deb-apt-ce5e32e0-a0e2-4e8d-b83b-e353a44ba19d
456457
REPO_DISTRO: ubuntu
457458
REPO_RELEASE: jammy
458459
ubuntu-jammy-arm64:
459460
TYPE: deb
460461
ARCH: arm64
461-
REPO_ID: 61faea6cea3a770ab120ac8a
462+
REPO_ID: repositories-deb-apt-ce5e32e0-a0e2-4e8d-b83b-e353a44ba19d
462463
REPO_DISTRO: ubuntu
463464
REPO_RELEASE: jammy
465+
464466
# debian-buster-amd64:
465467
# TYPE: deb
466468
# ARCH: amd64
@@ -499,30 +501,32 @@ stages:
499501
# REPO_ID: 5e5ed94a523a8019fe47607e
500502
# REPO_DISTRO: centos
501503
# REPO_RELEASE: 8
504+
502505
rhel-8-x86_64:
503506
TYPE: rpm
504507
ARCH: amd64
505-
REPO_ID: 5d4470e1eebce7156eee5407
508+
REPO_ID: repositories-rpm-rpm-825ad4f6-c3fb-48b0-8f61-acb58e2fff7c
506509
REPO_DISTRO: rhel
507510
REPO_RELEASE: 8
508511
rhel-8-aarch64:
509512
TYPE: rpm
510513
ARCH: arm64
511-
REPO_ID: 5d4470e1eebce7156eee5407
514+
REPO_ID: repositories-rpm-rpm-825ad4f6-c3fb-48b0-8f61-acb58e2fff7c
512515
REPO_DISTRO: rhel
513516
REPO_RELEASE: 8
514517
rhel-9-x86_64:
515518
TYPE: rpm
516519
ARCH: amd64
517-
REPO_ID: 627067cc3ac6d7548f4d66cd
520+
REPO_ID: repositories-rpm-rpm-f225b6b6-c414-4abb-a80d-5b8bdb8bc757
518521
REPO_DISTRO: rhel
519522
REPO_RELEASE: 9
520523
rhel-9-aarch64:
521524
TYPE: rpm
522525
ARCH: arm64
523-
REPO_ID: 627067cc3ac6d7548f4d66cd
526+
REPO_ID: repositories-rpm-rpm-f225b6b6-c414-4abb-a80d-5b8bdb8bc757
524527
REPO_DISTRO: rhel
525528
REPO_RELEASE: 9
529+
526530
# fedora-34-x86_64:
527531
# TYPE: rpm
528532
# ARCH: amd64
@@ -575,53 +579,71 @@ stages:
575579
pipeline: $(pipelineId)
576580
runVersion: "specific"
577581
runId: ${{ parameters.artifactBuildId }}
578-
- task: DownloadPackage@1
579-
displayName: "Download repoclient"
582+
- task: PipAuthenticate@1
580583
inputs:
581-
packageType: 'upack'
582-
feed: '9b6b54d1-85ce-4ff5-8faa-608b4a183fc6/fe61ad7c-682d-4a30-ae2e-6891a3b27dde'
583-
view: '2e6dbd24-c57a-430c-9148-c2cf257a62ae'
584-
definition: '5dc48a28-dc78-4d14-9a8b-4981783b402d'
585-
version: '2.2.1'
586-
downloadPath: $(system.defaultWorkingDirectory)/dist/tool
584+
artifactFeeds: 'release/aztfy'
587585
- script: |
588586
set -e
589-
sudo apt install -y ./dist/tool/azure-repoapi-client_2.2.1_amd64.deb
590-
mkdir ~/.repoclient
591-
cat << EOF > ~/.repoclient/config.json
592-
{
593-
"server": "azure-apt-cat.cloudapp.net",
594-
"port": "443",
595-
"AADClientId": "$(LINUX_REPO_SP_CLIENT_ID)",
596-
"AADClientSecret": "$(LINUX_REPO_SP_CLIENT_SECRET)",
597-
"AADResource": "https://microsoft.onmicrosoft.com/945999e9-da09-4b5b-878f-b66c414602c0",
598-
"AADTenant": "72f988bf-86f1-41af-91ab-2d7cd011db47",
599-
"AADAuthorityUrl": "https://login.microsoftonline.com",
600-
"repositoryId": "IGNORE"
601-
}
587+
pip install pyOpenSSL --upgrade
588+
pip install pmc-cli
589+
displayName: "Install PMC"
590+
- task: AzureKeyVault@2
591+
displayName: "Get PMC prod certificate"
592+
inputs:
593+
azureSubscription: 'aztfy_pmc'
594+
KeyVaultName: 'aztfy-pmc'
595+
SecretsFilter: 'PMCProdCertificate'
596+
RunAsPreJob: false
597+
- script: |
598+
set -e
599+
pmc_dir=~/.config/pmc
600+
mkdir -p $pmc_dir
601+
echo "$PMC_CERT" > $pmc_dir/aztfexport.pem
602+
cat << EOF > $pmc_dir/settings.toml
603+
[prod]
604+
base_url = "https://pmc-ingest.trafficmanager.net/api/v4"
605+
msal_client_id = "${PMC_CLIENT_ID}"
606+
msal_scope = "api://d48bb382-20ec-41b9-a0ea-07758a21ccd0/.default"
607+
msal_cert_path = "$pmc_dir/aztfexport.pem"
608+
msal_SNIAuth = true
609+
msal_authority = "https://login.microsoftonline.com/MSAzureCloud.onmicrosoft.com"
602610
EOF
603611
pkg=(./dist/pkg/*.${TYPE})
604612
[[ ${#pkg[@]} == 1 ]] || { echo "not exactly one target packages found: $(declare -p pkg)" > 2; exit 1; }
605613
pkg=${pkg[0]}
606614
607615
# Allow error's to occur prior to quit the task, as we are capturing the command output, otherwise, we will have no chance to output that in stdout/stderr.
608616
set +e
609-
ret=$(repoclient package add -r ${REPO_ID} $pkg)
610-
[[ $? == 0 ]] || { echo "Error: repoclient package add failed: $ret" >&2; exit 1; }
611-
echo -e "repoclient package add returns:\n$ret\n"
612-
613-
location=$(jq -r '.Location' <<< $ret)
614-
package_id=${location##*/}
615-
[[ -n $package_id ]] || { echo "Error: empty package id got" >&2; exit 1; }
616-
echo "package id: $package_id"
617-
618-
ret=$(repoclient package check $package_id)
619-
[[ $? == 0 ]] || { echo "Error: repoclient package check failed: $ret" >&2; exit 1; }
620-
echo -e "repoclient package check returns:\n$ret\n"
621-
displayName: "Publish via repoclient"
617+
618+
# Upload package
619+
ret=$(pmc package upload $pkg)
620+
[[ $? == 0 ]] || { echo "Error: pmc package upload failed: $ret" >&2; exit 1; }
621+
echo -e "pmc package upload returns:\n$ret\n"
622+
623+
id=$(jq -r '.[0].id' <<< $ret)
624+
[[ -n $id ]] || { echo "Error: empty package id got" >&2; exit 1; }
625+
echo "package id: $id"
626+
627+
# Link package to repo
628+
args=(repo package update --add-packages $id $REPO_ID)
629+
if [[ $TYPE == deb ]]; then
630+
args+=($REPO_RELEASE)
631+
fi
632+
ret=$(pmc "${args[@]}")
633+
[[ $? == 0 ]] || { echo "Error: pmc repo package update --add-packages: $ret" >&2; exit 1; }
634+
echo -e "pmc repo package update --add-packages returns:\n$ret\n"
635+
636+
# Publish repo
637+
ret=$(pmc repo publish $REPO_ID)
638+
[[ $? == 0 ]] || { echo "Error: pmc repo publish: $ret" >&2; exit 1; }
639+
echo -e "pmc repo publish returns:\n$ret\n"
640+
displayName: "Publish via pmc"
622641
env:
623642
TYPE: $(TYPE)
624643
REPO_ID: $(REPO_ID)
644+
REPO_RELEASE: $(REPO_RELEASE)
645+
PMC_CLIENT_ID: $(PMC_CLIENT_ID)
646+
PMC_CERT: $(PMCProdCertificate)
625647
- script: |
626648
set -e
627649

0 commit comments

Comments
 (0)