Skip to content

Instantly share code, notes, and snippets.

View TomerAdmon's full-sized avatar

Tomer Admon TomerAdmon

  • Tel Aviv, Israel
View GitHub Profile
@TomerAdmon
TomerAdmon / github_issues_to_csv.rb
Last active December 26, 2016 08:50 — forked from tkarpinski/github_issues_to_csv.rb
Exports Github issues to CSV (API v3)
require 'octokit'
require 'csv'
require 'date'
# Export Issue list from GitHub in a CSV form.
# mistone will be taken from the milestone column or will set to tentative is such label exist.
# the labels bug, technical, test plan needed and test plan ready will be set in the type column.
#GitHub credentials
USERNAME="USER"
@TomerAdmon
TomerAdmon / RemoveTeamCityFeature.ps1
Created December 28, 2016 16:48
Remove TeamCity feature from all your builds
##$secpasswd = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
##$mycreds = New-Object System.Management.Automation.PSCredential (“USERNAME”, $secpasswd)
$TEAMCITY_URL = "http://tc"
$FEATURE_NAME = "jetbrains.agent.free.space"
$mycreds = Get-Credential
$builds = [xml](Invoke-RestMethod -Method Get ($TEAMCITY_URL + "/httpAuth/app/rest/buildTypes") -Credential $mycreds)
foreach ($build in $builds.buildTypes.buildType)
{
@TomerAdmon
TomerAdmon / UpdateCheckoutMode.ps1
Created December 28, 2016 16:51
Update all build configuration in TeamCity to checkout on agent
$TEAMCITY_URL = "http://tc"
##$secpasswd = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
##$mycreds = New-Object System.Management.Automation.PSCredential (“USERNAME”, $secpasswd)
$mycreds = Get-Credential
$builds = [xml](Invoke-RestMethod -Method Get ($TEAMCITY_URL + "/httpAuth/app/rest/buildTypes") -Credential $mycreds)
foreach ($build in $builds.buildTypes.buildType)
@TomerAdmon
TomerAdmon / UnpinTeamCityBuilds.ps1
Created December 28, 2016 16:55
Unpin all builds except the last 10 from specific TeamCity build configuration
$TEAMCITY_URL = "http://tc"
$BUILD_TYPE = "BuildType"
##$secpasswd = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
##$mycreds = New-Object System.Management.Automation.PSCredential (“USERNAME”, $secpasswd)
$mycreds = Get-Credential
$builds = [xml](Invoke-RestMethod -Method Get ($TEAMCITY_URL + "/httpAuth/app/rest/buildTypes/id:" + $BUILD_TYPE + "/builds/?locator=count:1000000") -Credential $mycreds)
@TomerAdmon
TomerAdmon / RemoveAgentConfiguration.ps1
Created December 28, 2016 16:58
Remove an agent requiremnet from build configurations in TeamCIty
$TEAMCITY_URL = "http://tc"
$AGENT_REQUIREMENT = "DotNetFramework4.5_x86"
#$secpasswd = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
#$mycreds = New-Object System.Management.Automation.PSCredential (“USERNAME”, $secpasswd)
mycreds = Get-Credential
$builds = [xml](Invoke-RestMethod -Method Get ($TEAMCITY_URL + "/httpAuth/app/rest/buildTypes") -Credential $mycreds)
@TomerAdmon
TomerAdmon / DownloadLastBuildArtifact.ps1
Created December 28, 2016 20:33
Download artifacts for the last successful build from TeamCIty
$FOLDER_NAME = "DownlodedFiles"
$TEAM_CITY = 'http://TC'
$BUILD_TYPE_ID = "Trunk_Ci_FastCi_Build"
$FILES_TO_DOWNLOAD = ".zip"
$folderName = (".\" + $FOLDER_NAME)
If (Test-Path $folderName){
Remove-Item $folderName
}
@TomerAdmon
TomerAdmon / DeclareNewPivotFromTable.sql
Created December 28, 2016 20:42
Create a new table with pivoted data from the original table
declare
@cols nvarchar(max),
@sele nvarchar(max),
@stmt nvarchar(max)
select @cols = isnull(@cols + ', ', '') + '[' + T.ReleasedVersion + ']' from (select distinct ReleasedVersion from DriversAndLibraries Where ReleasedVersion <> '') as T
select @sele = isnull(@sele + ', ', '') + 'max([' + T.ReleasedVersion + ']) AS ' + '[' + T.ReleasedVersion + ']' from (select distinct ReleasedVersion from DriversAndLibraries Where ReleasedVersion <> '') as T
PRINT @sele
select @stmt = '
@TomerAdmon
TomerAdmon / RetryCMD-TeamCity-MetaRunner.xml
Created January 18, 2017 15:56
TeamCity custom Meta-Runner that uses PowerShell to retry a command line action till success
<!--
Hi,
This is a TeamCity meta-runner that can be added to any TeamCity server for retry a command line task till success.
This meta-runner come usuful with command line utilities line npm where we see unstableness from time to time.
This meta-runner will get only two parameter by default: the command and the working directory to run the commnad from.
The code will then retry the command from 3 times till exit-code of 0 is reached.
-->
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="RetryCommandLine">
<description>TeamCity custom Meta-Runner that uses PowerShell to retry a command line action till success</description>
@TomerAdmon
TomerAdmon / zendesk_query.ps1
Created July 24, 2017 13:27
PowerShell script that query Zendesk using REST API to find all tickets that some users were involved in since a specific date.
$user_names = "My User", "Another User"
$search_since = "2017-03-01"
$global:zendesk_user_name = "username"
$global:zendesk_password = "password"
$global:zendesk_address = "zendesk_address"
function CreateAuthorizationHeader()
{
$pair = "$($zendesk_user_name):$($zendesk_password)"
sudo yum install httpd -y
sudo systemctl enable httpd.service
sudo systemctl restart httpd.service