Created
March 16, 2016 15:48
-
-
Save ipcrm/3dba700e8147f38d6ba5 to your computer and use it in GitHub Desktop.
Code Manager Sync via PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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