asking on the GCM Github issues pageの後、GCMはファイルからの資格情報の読み取りをサポートしていません。
しかし、私の目標は、非対話型の資格情報を許可することです。プログラムでGCMが使用するWindows資格情報ストアに資格情報を追加することをサポートしています。 bundled librariesを使用することにより(binaries here)私は一緒に私たちはシェフによるマシンのプロビジョニング中に資格情報を追加することができPowerShellスクリプトを置くことができました:
Add-Type -Path 'c:\path\to\gcm-v1.4.0\Microsoft.Alm.Authentication.dll'
$credentials = New-Object -TypeName Microsoft.Alm.Authentication.Credential('someuser', 'secret')
$targetUri = New-Object -TypeName Microsoft.Alm.Authentication.TargetUri('https://git.example.com/projects')
$namespace = "git"
$secretStore = New-Object -TypeName Microsoft.Alm.Authentication.SecretStore($namespace, $null, $null, $null)
$foundCredentials = $null
$secretStore.ReadCredentials($targetUri, [ref] $foundCredentials)
if ($foundCredentials -ne $null) {
echo "Credentials already found, not inserting"
} else {
echo "Inserting stored credentials"
$secretStore.WriteCredentials($targetUri, $credentials)
}
これはジェンキンススレーブがユーザーの操作なしでGitのクローンを行うことができます。
注:あなたがそうでなければ、彼らがロードされない「無制限」の実行ポリシーと同様にGCMに含まunblockのDLLでPowerShellスクリプトを実行する必要があります。