Skip to content

Instantly share code, notes, and snippets.

View MarcusFelling's full-sized avatar

Marcus Felling MarcusFelling

View GitHub Profile
<#
.Description
Script used to bulk update Azure Pipeline release definition's WindowsMachineFileCopy from v1 to v2
.Example
.\Update-ReleaseDefinitionsWindowsMachineFileCopyTask.ps1 -PAT "NoTaReAlPaT" -AzureDevOpsProjectURL "https://vsrm.dev.azure.com/{organization}/{project}"
#>
[CmdletBinding()]
Param
@MarcusFelling
MarcusFelling / example.yml
Created January 23, 2019 00:46
Audhari Poornimarao YAML example
# Build app using Azure Pipelines
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript?view=vsts
pool:
vmImage: 'vs2017-win2016'
steps:
– script: echo hello world
– task: NodeTool@0
inputs:
versionSpec: '8.x'
<#
.Description
Script used to gather all releases that have been successfully deployed to QA,
but not yet promoted to Prod environments. Outputs release definition name and URL of release to LatestReleases.html
.Example
.\Get-ReleasesNotInProduction.ps1 -PAT "NoTaReAlPaT" -AzureDevOpsProjectURL "https://vsrm.dev.azure.com/{organization}/{project}"
#>
[CmdletBinding()]
$dotnet = Get-Process dotnet -ErrorAction SilentlyContinue
If($dotnet){
taskkill.exe /F /IM dotnet.exe
}
Else{
"No dotnet.exe tasks to kill"
}
<#
.DESCRIPTION
Creates a new release for the specified release definition name, using the latest artifact versions available
.Parameter PAT
Personal Access token. It's recommended to use a service account and pass via encrypted build definition variable.
https://docs.microsoft.com/en-us/vsts/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts
.Parameter ReleaseDefinitionName
Name of release definition to create a release for
.Notes
-Parameters are outside of functions in order to be passed by TFS build definition variables
$VersionRegex = "\d+\.\d+\.\d+\.\d+"
$Files = Get-ChildItem $Env:BUILD_SOURCESDIRECTORY -recurse -include "*Properties*" |
?{ $_.PSIsContainer } |
ForEach { Get-ChildItem -Path $_.FullName -Recurse -include AssemblyInfo.* }
If($Files){
"Will apply $env:Version to $($Files.count) files."
ForEach ($File in $Files) {
$Filecontent = Get-Content($File)
attrib $File -r
$Filecontent -replace $VersionRegex, $env:Version | Out-File $File
@MarcusFelling
MarcusFelling / VSTSAgentInstall.rb
Last active December 26, 2017 16:43
Chef recipe to install VSTS agents
# Array of agents to create
example_agents = ['Example-1', "Example-2", "Example-3", "Example-4", "Example-5", "Example-6"]
example_agentpool = ''
install_dir = 'H:\\agents\\'
sv_user = '' # Windows log on account for agent service
sv_password = ''
vsts_url = 'https://youraccount.visualstudio.com'
vsts_token = '' # Temporary PAT to use when installing the agents
# Download install files from S3
# Part 2 of 2
# Part 1 Places EC2 instance into autoscaling group's standby mode.
# Part 2 Exits standby mode and waits for instance to be InService.
param (
[Parameter(Mandatory=$true)][string]$ASGEnterStandbyDeployStep, # Deploy step name of EnterStandby.ps1
[Parameter(Mandatory=$true)][string]$ASGNameVariable, # Variable name that is set by EnterStandby.ps1 for ASG Name
[Parameter(Mandatory=$true)][string]$registrationCheckInterval,
[Parameter(Mandatory=$true)][string]$maxRegistrationCheckCount
)
# Part 1 of 2
# Part 1 Places EC2 instance into autoscaling group's standby mode.
# Part 2 Exits standby mode and waits for instance to be InService.
param (
[Parameter(Mandatory=$true)][string]$ASGNameVariable # Passed in Octopus script step
)
# Get EC2 Instance
Try
{
$response = Invoke-RestMethod -Uri "http://169.254.169.254/latest/meta-data/instance-id" -Method Get
@MarcusFelling
MarcusFelling / VSTS.yml
Created November 23, 2017 15:35
Example VSTS YAML build with 5 phases
phases:
- phase: CD
queue: LEP
steps:
- task: PowerShell@1
displayName: ExtConfigs_PreBuild.ps1
inputs:
scriptType: filePath
scriptName: "$(repo.BuildScripts)/ExtConfigs_PreBuild.ps1"
arguments: ''