Skip to content

Instantly share code, notes, and snippets.

@ipcrm
Created March 16, 2016 15:48
Show Gist options
  • Save ipcrm/3dba700e8147f38d6ba5 to your computer and use it in GitHub Desktop.
Save ipcrm/3dba700e8147f38d6ba5 to your computer and use it in GitHub Desktop.
Code Manager Sync via PowerShell
#the top type is needed to deal with an untrusted cert
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$puppetenv = "production"
$token = 'put your longer than maybe it should be token here’
$url = "https://yourserver:8170/code-manager/v1/deploys?token=$token"
$headers = @{"Content-Type"= "application/json"}
#to do one env
$body = "{`"environments`": [`"$puppetenv`"], `"wait`": true}"
#to deploy all
#$body = '{"deploy-all": true}'
$result = Invoke-WebRequest -Uri $url -Headers $headers -Body $body -Method POST
$result.Content | ConvertFrom-Json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment