我有代码可以在没有启用凭据的情况下在 Jenkins 上创建/更新作业。
const string FORMAT = "http://{0}:{1}/createItem?name={2}";
var path =
string.Format(
FORMAT,
this.config.JenkinsServer,
this.config.JenkinsPort,
buildName);
this.http.UploadString(
path,
definition,
new Header(HttpRequestHeader.ContentType, "text/xml"));
Run Code Online (Sandbox Code Playgroud)
现在,我想通过启用凭据并在创建新作业时指定用户名/密码来向前迈进一步。我在 Jenkins 上找到了一篇关于 Authenticating scripted clients 的文章,但没有 C# 中的代码示例,无法弄清楚如何去做。
如何在启用凭据的情况下在 Jenkins 上创建/更新作业?
[更新] 像这个链接一样在 url 上指定用户名和密码也不起作用。
我想在 Puppet 上安装/卸载 Windows 服务,但找不到执行此操作的内置函数。我想出了下面的脚本,它运行良好,但很丑陋。
exec{ "install_service" :
command => "${Sys32}\\cmd.exe /c installutil -i /LogFile=\"${logFile}\" \"${sourcePath}\" | exit 0",
path => $Framework4x64,
}
Run Code Online (Sandbox Code Playgroud)
有更好的方法吗?我尝试搜索插件,但尚未找到。
我对TDD很新.我正在阅读TDD By Example并且它说"永远不要尝试使用相同的常量来表示不止一件事"并且它显示了一个Plus()方法示例.
在我看来,Plus(1,1)使用相同的常数值和Plus(1,2)之间没有区别.我想知道在测试方法中使用相同的常量值有什么优缺点?
我想确保路径总是以 结束,\我尝试使用 Path.Combine 作为下面的代码。
我希望System.IO.Path.Combine("xxx", System.IO.Path.DirectorySeparatorChar.ToString())返回,xxx\但它只返回\
System.IO.Path.Combine("xxx", "\\", "zz")我所期望的也是如此,xxx\zz但结果是\zz
以下是我做过的测试。

我不确定这是期望的行为还是错误。