Skip to content

Instantly share code, notes, and snippets.

View fluffy-cakes's full-sized avatar

Fluffy-Cakes fluffy-cakes

View GitHub Profile
$PSVersionTable
$ErrorActionPreference = "Stop"
$branch = $Env:BUILD_SOURCEBRANCHNAME
$headers = @{
"Authorization" = "Bearer ${Env:SYSTEM_ACCESSTOKEN}"
"Content-Type" = "application/json"
}
$PSVersionTable
$ErrorActionPreference = "Stop"
$sourceBranch = $(${Env:SYSTEM_PULLREQUEST_SOURCEBRANCH} -split "refs/heads/")[-1]
# We need to checkout the branch in order to compare the differences in files changed from develop branch
Set-Location -Path "${Env:SYSTEM_DEFAULTWORKINGDIRECTORY}/${Env:BUILD_REPOSITORY_NAME}"
git checkout $sourceBranch
@fluffy-cakes
fluffy-cakes / prStats.ps1
Last active August 21, 2023 20:57
azdo_prStats
<#
.SYNOPSIS
An easy text-based view of how quickly PRs are being approved.
.DESCRIPTION
This script was born out of the need to help a client understand how quickly we are progressing with PR approvals.
It's a handy way to view how a particular repo, or all the repos within an Azure DevOps project is progressing for
PR approvals.
It will find the longest running PR and set it's text-based graphical view at 100% noted with the "-" for each 1%.
@fluffy-cakes
fluffy-cakes / azdo_createEnvs.ps1
Created November 12, 2021 14:23
AzDO Dynamically Create Environments
<#
.SYNOPSIS
Dynamically creates Azure DevOps "Environments" with security permissions, approvers and branch control.
.DESCRIPTION
The variable "$envList" is an object that sets the high level management groups and their settings which
will be used to create each environment;
approval = enable approval checks
branch_control = limit deployments only to ref/heads/main
env_group = which of the three environment groups the management group belows (nonprod, preprod, prod)
@fluffy-cakes
fluffy-cakes / example.tf
Created February 26, 2021 17:34
How to call the Azure API directly via PowerShell from within Terraform
resource "null_resource" "deploy_workspace_settings" {
provisioner "local-exec" {
command = <<EOT
Import-Module ${path.module}/tf_azure_api_call.psm1
New-WorkspaceSetting `
-ClientId "${var.ARM_CLIENT_ID}" `
-ClientSecret "${var.ARM_CLIENT_SECRET}" `
-SubscriptionId "${var.ARM_SUBSCRIPTION_ID}" `
-TenantId "${var.ARM_TENANT_ID}" `
-WorkspaceId "${var.workspace_id}" `
[CmdletBinding()]
param(
[ValidateNotNullOrEmpty()]
[string]$repo,
[ValidateNotNullOrEmpty()]
[string]$token,
[ValidateNotNullOrEmpty()]
[int]$PRfrom,
[ValidateNotNullOrEmpty()]
[int]$PRto
@fluffy-cakes
fluffy-cakes / ConvertTo-Markdown.ps1
Created January 26, 2021 16:44 — forked from jdhitsolutions/ConvertTo-Markdown.ps1
Convert pipeline output to a markdown document
#requires -version 5.0
Function ConvertTo-Markdown {
<#
.Synopsis
Convert pipeline output to a markdown document.
.Description
This command is designed to accept pipelined output and create a markdown document. The pipeline output will formatted as a text block. You can optionally define a title, content to appear before the output and content to appear after the output.
The command does not create a text file. You need to pipe results from this command to a cmdlet like Out-File or Set-Content. See examples.
.Parameter Title