From dd399bcab41317bb4b1d92f32d816dfe95d4e474 Mon Sep 17 00:00:00 2001 From: Marcus Felling Date: Thu, 24 Jun 2021 03:13:00 -0500 Subject: [PATCH] [Ubuntu] Adding Bicep CLI (#3639) * Add Bicep CLI to Ubuntu images * Use helper download_with_retries * remove bicep from deprecated 16.04 image * formatting Co-authored-by: Marcus Felling --- .../SoftwareReport/SoftwareReport.Generator.ps1 | 1 + .../SoftwareReport/SoftwareReport.Tools.psm1 | 6 ++++++ images/linux/scripts/installers/bicep.sh | 16 ++++++++++++++++ images/linux/scripts/tests/Tools.Tests.ps1 | 6 ++++++ images/linux/ubuntu1804.json | 1 + images/linux/ubuntu2004.json | 1 + 6 files changed, 31 insertions(+) create mode 100644 images/linux/scripts/installers/bicep.sh diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 004e15657..3589044ee 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -109,6 +109,7 @@ $toolsList = @( (Get-AzCopyVersion), (Get-BazelVersion), (Get-BazeliskVersion), + (Get-BicepVersion), (Get-CodeQLBundleVersion), (Get-CMakeVersion), (Get-DockerMobyClientVersion), diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index 35a74f684..202920a97 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -26,6 +26,12 @@ function Get-BazeliskVersion { return "Bazelisk $bazeliskVersion" } +function Get-BicepVersion { + (bicep --version | Out-String) -match "bicep cli version (?\d+\.\d+\.\d+)" | Out-Null + $bicepVersion = $Matches.Version + return "Bicep $bicepVersion" +} + function Get-CodeQLBundleVersion { $CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*" $CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Select-Object -First 1 -Expand FullName diff --git a/images/linux/scripts/installers/bicep.sh b/images/linux/scripts/installers/bicep.sh new file mode 100644 index 000000000..20c0482c2 --- /dev/null +++ b/images/linux/scripts/installers/bicep.sh @@ -0,0 +1,16 @@ +#!/bin/bash -e +################################################################################ +## File: bicep.sh +## Desc: Installs bicep cli +################################################################################ + +source $HELPER_SCRIPTS/install.sh + +# Install Bicep CLI +download_with_retries "https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64" "." "bicep.bin" +# Mark it as executable +chmod +x ./bicep.bin +# Add bicep to PATH (requires admin) +sudo mv ./bicep.bin /usr/local/bin/bicep + +invoke_tests "Tools" "Bicep" \ No newline at end of file diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 76f4ba4d3..9ae92516d 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -8,6 +8,12 @@ Describe "azcopy" { } } +Describe "Bicep" { + It "Bicep" { + "bicep --version" | Should -ReturnZeroExitCode + } +} + Describe "Rust" { It "Rustup is installed" { "rustup --version" | Should -ReturnZeroExitCode diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index f6ede73f9..03fb8d806 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -196,6 +196,7 @@ "{{template_dir}}/scripts/installers/azure-cli.sh", "{{template_dir}}/scripts/installers/azure-devops-cli.sh", "{{template_dir}}/scripts/installers/basic.sh", + "{{template_dir}}/scripts/installers/bicep.sh", "{{template_dir}}/scripts/installers/aliyun-cli.sh", "{{template_dir}}/scripts/installers/apache.sh", "{{template_dir}}/scripts/installers/aws.sh", diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 0d70fc4d7..c6d10ae44 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -196,6 +196,7 @@ "{{template_dir}}/scripts/installers/azure-cli.sh", "{{template_dir}}/scripts/installers/azure-devops-cli.sh", "{{template_dir}}/scripts/installers/basic.sh", + "{{template_dir}}/scripts/installers/bicep.sh", "{{template_dir}}/scripts/installers/aliyun-cli.sh", "{{template_dir}}/scripts/installers/apache.sh", "{{template_dir}}/scripts/installers/aws.sh",