Repository: Azure/ARO-RP
Pull request #1880 (2021-12-14 22:13:01)

Add subscription of keyvault to e2e template
### Which issue this PR addresses:

Fixes issues with failure to find the service account because the wrong subscription is set by default for the service principal. 

### What this PR does / why we need it:

Should fix our e2e

### Test plan for issue:

Check if e2e passes on this PR (or at least gets past the error portion)

### Is there any documentation that needs to be updated for this PR?

~This should be parameterized instead of explicitly set, but I don't believe I have the proper permissions in ADO to do so, hence this PR in such state.~ I can see the variables after logging into ADO with my GitHub account.  This should work, waiting on e2e to pass and we can merge.  


Patch:
diff --git a/.pipelines/onebranch/pipeline.image.mirror.official.yml b/.pipelines/onebranch/pipeline.image.mirror.official.yml
new file mode 100644
index 000000000..5f4231816
--- /dev/null
+++ b/.pipelines/onebranch/pipeline.image.mirror.official.yml
@@ -0,0 +1,51 @@
+#################################################################################
+#                               OneBranch Pipelines                             #
+# This pipeline was created by EasyStart from a sample located at:              #
+#   https://aka.ms/obpipelines/easystart/samples                                #
+# Documentation:  https://aka.ms/obpipelines                                    #
+# Yaml Schema:    https://aka.ms/obpipelines/yaml/schema                        #
+# Retail Tasks:   https://aka.ms/obpipelines/tasks                              #
+# Support:        https://aka.ms/onebranchsup                                   #
+#################################################################################
+
+trigger: none
+pr: none
+
+parameters:
+- name: vsoDeployerBuildID
+  type: string
+  default: latest
+
+variables:
+  Cdp_Definition_Build_Count: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
+  LinuxContainerImage: cdpxlinux.azurecr.io/user/aro/ubi8-gotoolset-1.14.12:2021.10.12   # Docker image which is used to build the project https://aka.ms/obpipelines/containers
+  Debian_Frontend: noninteractive
+
+resources:
+  repositories:
+  - repository: templates
+    type: git
+    name: OneBranch.Pipelines/GovernedTemplates
+    ref: refs/heads/main
+  - repository: rhado
+    type: git
+    name: ARO.Pipelines
+
+extends:
+  template: v2/OneBranch.Official.CrossPlat.yml@templates # https://aka.ms/obpipelines/templates
+  parameters:
+    globalSdl: # https://aka.ms/obpipelines/sdl
+      # tsa:
+      #  enabled: true # SDL results of non-official builds aren't uploaded to TSA by default.
+      # credscan:
+      #   suppressionsFile: $(Build.SourcesDirectory)\.config\CredScanSuppressions.json
+      policheck:
+        break: true # always break the build on policheck issues. You can disable it by setting to 'false'
+      suppression:
+        suppressionFile: $(Build.SourcesDirectory)\.gdn\.gdnsuppress
+        suppressionSet: default
+
+    stages:
+    - stage: Mirror_Images
+      jobs:
+      - template: .pipelines/onebranch/templates/template-image-mirror.yml@self
diff --git a/.pipelines/onebranch/pipeline.image.mirror.pullrequest.yml b/.pipelines/onebranch/pipeline.image.mirror.pullrequest.yml
new file mode 100644
index 000000000..e35296a6e
--- /dev/null
+++ b/.pipelines/onebranch/pipeline.image.mirror.pullrequest.yml
@@ -0,0 +1,54 @@
+#################################################################################
+#                               OneBranch Pipelines                             #
+# This pipeline was created by EasyStart from a sample located at:              #
+#   https://aka.ms/obpipelines/easystart/samples                                #
+# Documentation:  https://aka.ms/obpipelines                                    #
+# Yaml Schema:    https://aka.ms/obpipelines/yaml/schema                        #
+# Retail Tasks:   https://aka.ms/obpipelines/tasks                              #
+# Support:        https://aka.ms/onebranchsup                                   #
+#################################################################################
+
+trigger: none
+pr: none
+
+parameters:
+- name: vsoDeployerBuildID
+  type: string
+  default: latest
+
+variables:
+  Cdp_Definition_Build_Count: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
+  LinuxContainerImage: cdpxlinux.azurecr.io/user/aro/ubi8-gotoolset-1.14.12:2021.10.12   # Docker image which is used to build the project https://aka.ms/obpipelines/containers
+  Debian_Frontend: noninteractive
+
+resources:
+  repositories:
+  - repository: templates
+    type: git
+    name: OneBranch.Pipelines/GovernedTemplates
+    ref: refs/heads/main
+  - repository: rhado
+    type: git
+    name: ARO.Pipelines
+  - repository: rpconfig
+    type: git
+    name: RP-Config
+
+extends:
+  template: v2/OneBranch.NonOfficial.CrossPlat.yml@templates # https://aka.ms/obpipelines/templates
+  parameters:
+    globalSdl: # https://aka.ms/obpipelines/sdl
+      # tsa:
+      #  enabled: true # SDL results of non-official builds aren't uploaded to TSA by default.
+      # credscan:
+      #   suppressionsFile: $(Build.SourcesDirectory)\.config\CredScanSuppressions.json
+      policheck:
+        break: true # always break the build on policheck issues. You can disable it by setting to 'false'
+      suppression:
+        suppressionFile: $(Build.SourcesDirectory)\.gdn\.gdnsuppress
+        suppressionSet: default
+
+    stages:
+    - stage: Mirror_Images
+      jobs:
+      - template: .pipelines/onebranch/templates/template-image-mirror.yml@self
diff --git a/.pipelines/onebranch/scripts/mirroring.sh b/.pipelines/onebranch/scripts/mirroring.sh
new file mode 100644
index 000000000..106d5c197
--- /dev/null
+++ b/.pipelines/onebranch/scripts/mirroring.sh
@@ -0,0 +1,13 @@
+SERVICE_GROUP_ROOT=$BUILD_SOURCESDIRECTORY/ARO.Pipelines/ev2/Mirroring/ServiceGroupRoot
+EV2_BIN=$SERVICE_GROUP_ROOT/bin
+ARO_DIR=$BUILD_SOURCESDIRECTORY/deployer
+
+mkdir $OB_OUTPUTDIRECTORY
+
+cd $ARO_DIR
+tar -cvf $EV2_BIN/aro.tar aro
+cd $SERVICE_GROUP_ROOT/bin
+tar -rf $EV2_BIN/aro.tar mirror.sh
+rm mirror.sh
+
+cp -r $SERVICE_GROUP_ROOT $OB_OUTPUTDIRECTORY/ServiceGroupRoot/
diff --git a/.pipelines/onebranch/templates/template-image-mirror.yml b/.pipelines/onebranch/templates/template-image-mirror.yml
new file mode 100644
index 000000000..4f5776012
--- /dev/null
+++ b/.pipelines/onebranch/templates/template-image-mirror.yml
@@ -0,0 +1,28 @@
+jobs:
+- job: Mirror_Images
+  timeoutInMinutes: 360
+  pool:
+    type: linux
+
+  variables:   # More settings at https://aka.ms/obpipelines/yaml/jobs
+    ob_outputDirectory: $(Build.SourcesDirectory)/out     # this directory is uploaded to pipeline artifacts, reddog and cloudvault. More info at https://aka.ms/obpipelines/artifacts
+    vso-deployer-pipeline-id: 206753
+    vso-project-id: 5d69ab04-7ded-49dc-84d5-bbbcac4add8d
+
+  steps:
+  - checkout: rhado
+  - task: DownloadPipelineArtifact@2
+    displayName: Download Deployer
+    inputs:
+      buildType: specific
+      project: $(vso-project-id)
+      pipeline: $(vso-deployer-pipeline-id)
+      ${{ if eq(parameters.vsoDeployerBuildID, 'latest') }}:
+        buildVersionToDownload: FromBranch
+        branchName: refs/heads/master
+      downloadType: specific
+      downloadPath: $(Build.SourcesDirectory)/deployer
+      artifact: drop_Build_ARO_Build_ARO
+  - template: ./template-generate-ev2-manifests.yml
+    parameters:
+      generationType: mirroring


Test patch:
diff --git a/.pipelines/e2e.yml b/.pipelines/e2e.yml
index 63130c655..21b26b434 100644
--- a/.pipelines/e2e.yml
+++ b/.pipelines/e2e.yml
@@ -21,6 +21,7 @@ jobs:
     parameters:
       azureDevOpsJSONSPN: $(aro-v4-e2e-devops-spn)
   - script: |
+      az account set -s $AZURE_SUBSCRIPTION_ID
       export SECRET_SA_ACCOUNT_NAME=$(SECRET_SA_ACCOUNT_NAME)
       make secrets
       . secrets/env