Skip to content

Instantly share code, notes, and snippets.

@felickz
Last active April 17, 2024 08:37
Show Gist options
  • Save felickz/830d1aa9ba02eef8809789e4b1d05581 to your computer and use it in GitHub Desktop.
Save felickz/830d1aa9ba02eef8809789e4b1d05581 to your computer and use it in GitHub Desktop.
GHAzDO conditionally run tasks based on enablement

To conditionally run the GHAzDO tasks in a pipeline:

image

Use the following steps:

steps:
- bash: az devops configure --defaults organization='$(System.TeamFoundationCollectionUri)' project='$(System.TeamProject)' --use-git-aliases true
  displayName: 'Set default Azure DevOps organization and project'

- bash: echo "##vso[task.setvariable variable=advSecEnabled]$(az devops invoke --area Management --resource RepoEnablement --route-parameters repository='$(Build.Repository.Name)'  project='$(System.TeamProject)' --api-version '7.2-preview' --query advSecEnabled)"
  env:
    AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
  displayName: 'Set var for GHAzDO Enablement'

- task: AdvancedSecurity-Codeql-Init@1
  condition: eq(variables['advSecEnabled'], 'true')
  inputs:
    languages: 'javascript'

- task: AdvancedSecurity-Codeql-Autobuild@1
  condition: eq(variables['advSecEnabled'], 'true')

- task: AdvancedSecurity-Dependency-Scanning@1
  condition: eq(variables['advSecEnabled'], 'true')

- task: AdvancedSecurity-Codeql-Analyze@1
  condition: eq(variables['advSecEnabled'], 'true')
@0GiS0
Copy link

0GiS0 commented Apr 17, 2024

Thanks @felickz! If you think it makes sense, I can create a PR with this task in order to integrate it in our GHAzDO-Resources repo 🥲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment