Skip to content

Commit

Permalink
Add disabled NI task on pipeline builds (#75)
Browse files Browse the repository at this point in the history
* Add disabled NI task on pipeline builds

* Use pred version of task

* Rename task to Network Isolation

* NIMode variable -> parameter

* Correct parameter usage

* Reference parameters better again.

* Wrap parameter in quotes
  • Loading branch information
JuanCarlosGI authored Jun 21, 2024
1 parent c77f8f9 commit fe49cf5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .azuredevops/pipelines/official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ resources:
type: git
name: 1ESPipelineTemplates/MicroBuildTemplate
ref: refs/tags/release
parameters:
- name: NetworkIsolationMode
displayName: 'Network Isolation Mode'
type: string
default: Disabled
values:
- Disabled
- Audit
- Enforce
variables:
- template: /.azuredevops/pipelines/templates/variables.yml@self
- name: SignType
Expand Down Expand Up @@ -64,6 +73,9 @@ extends:
targetPath: $(ArtifactsDirectory)
artifactName: artifacts
steps:
- template: templates\network-isolation.yml
parameters:
NetworkIsolationMode: ${{ parameters.NetworkIsolationMode }}
- task: PowerShell@2
displayName: 'Update SignType, Build Number, and Add Build Tag for tagged commits'
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
Expand Down
26 changes: 26 additions & 0 deletions .azuredevops/pipelines/pr-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
variables:
- template: templates\variables.yml

parameters:
- name: NetworkIsolationMode
displayName: 'Network Isolation Mode'
type: string
default: Disabled
values:
- Disabled
- Audit
- Enforce

schedules:
- cron: '0 0 * * *'
displayName: Daily midnight build
Expand Down Expand Up @@ -33,6 +43,10 @@ jobs:
- job: Build
displayName: Build and Test
steps:
- template: templates\network-isolation.yml
parameters:
NetworkIsolationMode: ${{ parameters.NetworkIsolationMode }}

- checkout: self
# Fetch all history for versioning
fetchDepth: 0
Expand Down Expand Up @@ -73,6 +87,10 @@ jobs:
VsInstallDir: $(Build.ArtifactStagingDirectory)\vs
MSBuildPath: $(VsInstallDir)\MSBuild\Current\Bin\amd64\MSBuild.exe
steps:
- template: templates\network-isolation.yml
parameters:
NetworkIsolationMode: ${{ parameters.NetworkIsolationMode }}

- download: current
displayName: 'Download Build Artifacts'
artifact: artifacts
Expand Down Expand Up @@ -126,6 +144,10 @@ jobs:
VsInstallDir: $(Build.ArtifactStagingDirectory)\vs
MSBuildPath: $(VsInstallDir)\MSBuild\Current\Bin\amd64\MSBuild.exe
steps:
- template: templates\network-isolation.yml
parameters:
NetworkIsolationMode: ${{ parameters.NetworkIsolationMode }}

- download: current
displayName: 'Download Build Artifacts'
artifact: artifacts
Expand Down Expand Up @@ -178,6 +200,10 @@ jobs:
variables:
MSBuildPath: $(Build.SourcesDirectory)\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\amd64\MSBuild.exe
steps:
- template: templates\network-isolation.yml
parameters:
NetworkIsolationMode: ${{ parameters.NetworkIsolationMode }}

- download: current
displayName: 'Download Build Artifacts'
artifact: artifacts
Expand Down
11 changes: 11 additions & 0 deletions .azuredevops/pipelines/templates/network-isolation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
- name: NetworkIsolationMode
type: string
default: Disabled

steps:
- task: tse-cloudbuild.1es-networkisolation-tasks.661EE24A-9364-4A3B-A725-3CBEB6F35E4B.1ESNetworkIsolation@1
displayName: Network Isolation
condition: ne('${{ parameters.NetworkIsolationMode }}', 'Disabled')
inputs:
networkIsolationMode: ${{ parameters.NetworkIsolationMode }}

0 comments on commit fe49cf5

Please sign in to comment.