{"id":1179,"date":"2019-03-27T13:44:23","date_gmt":"2019-03-27T05:44:23","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=1179"},"modified":"2019-03-27T13:44:23","modified_gmt":"2019-03-27T05:44:23","slug":"jenkins-%e5%ae%9e%e7%8e%b0-net%e9%a1%b9%e7%9b%ae%e4%b8%80%e9%94%ae%e9%83%a8%e7%bd%b2","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=1179","title":{"rendered":"Jenkins \u5b9e\u73b0.net\u9879\u76ee\u4e00\u952e\u90e8\u7f72"},"content":{"rendered":"<p>\u4e00\u3001\u4e0b\u8f7d\u5b89\u88c5Jenkins \u00a0:<\/p>\n<p>\u5b98\u7f51\u5730\u5740\u00a0https:\/\/jenkins.io\/index.html \u00a0 \u5b89\u88c5\u6ca1\u4ec0\u4e48\u7279\u6b8a\u7684 \u5e38\u89c4\u5b89\u88c5\u5373\u53ef\u3002\u5b89\u88c5\u540e\u9ed8\u8ba4\u5360\u75288080\u7aef\u53e3\u3002\u53ef\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u3002<\/p>\n<p>\u4e8c\u3001\u914d\u7f6e\uff1a<\/p>\n<p>\u9996\u6b21\u8bbf\u95ee\uff0c\u4f1a\u63d0\u793a\u5b89\u88c5\u63d2\u4ef6\uff0c\u5982\u679c\u5b89\u88c5Jenkins\u7684\u670d\u52a1\u5668\u53ef\u4ee5\u8054\u7f51\uff0c\u9009\u62e9\u9700\u8981\u7684\u5b89\u88c5\u5373\u53ef\u3002\u4f46\u5982\u679c\u4e0d\u80fd\u8054\u7f51\uff0c\u8fd9\u91cc\u4e0d\u80fd\u9009\u62e9\u4efb\u4f55\u63d2\u4ef6\u5b89\u88c5\uff0c\u5426\u5219\u4f1a\u62a5\u9519\uff08\u540e\u9762\u4f1a\u81ea\u5df1\u4e0b\u8f7d\u63d2\u4ef6\u5305\u901a\u8fc7\u4e0a\u4f20\u7684\u65b9\u5f0f\u8fdb\u884c\u5b89\u88c5\uff09\u3002<\/p>\n<p>\u7136\u540e\u5c31\u662f\u6ce8\u518c\u4e00\u4e2a\u7ba1\u7406\u5458\u8d26\u53f7 \u5373\u53ef\u767b\u5f55\u8fdb\u884c\u914d\u7f6e\u4e86\u3002<\/p>\n<p>\u79bb\u7ebf\u5b89\u88c5\u63d2\u4ef6\uff1a<\/p>\n<p>\u63d2\u4ef6\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/updates.jenkins-ci.org\/download\/plugins\/<\/p>\n<p>\u4e0b\u8f7d\u597d\u5bf9\u5e94\u7684\u63d2\u4ef6\uff08\u4e00\u822c\u6700\u65b0\u7248\u5c31\u884c,\u6ce8\u610f\u63d2\u4ef6\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u8981\u4e0b\u8f7d\u6574\u4e2a\u4f9d\u8d56\u6811\u7684\u6240\u6709\u4e0b\u6e38\u63d2\u4ef6\u5e76\u4ece\u4e0b\u5f80\u4e0a\u5b89\u88c5\uff0c\u5426\u5219\u4f1a\u51fa\u9519\uff0c\u4e5f\u53ef\u4ee5\u6839\u636e\u51fa\u9519\u63d0\u793a\u4f9d\u6b21\u4e0b\u8f7d\u7f3a\u5c11\u7684\u63d2\u4ef6\uff09\u3002<\/p>\n<p>\u7cfb\u7edf\u7ba1\u7406&#8211;&gt;\u7ba1\u7406\u63d2\u4ef6&#8211;&gt;\u9ad8\u7ea7&#8211;&gt;\u4e0a\u4f20\u63d2\u4ef6&#8211;&gt;\u9009\u62e9\u6587\u4ef6&#8211;&gt;\u9009\u62e9\u521a\u624d\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff08\u4e00\u6b21\u53ea\u80fd\u9009\u62e9\u4e00\u4e2a\uff0c\u4e00\u822c\u4e3ahpi\u683c\u5f0f\uff09\uff0c\u7136\u540e\u4f1a\u81ea\u52a8\u8fdb\u884c\u5b89\u88c5\u3002\u5982\u679c\u5b89\u88c5\u5931\u8d25\uff0c\u4e00\u822c\u662f\u7531\u4e8e\u7f3a\u5c11\u4f9d\u8d56\u63d2\u4ef6\u5f15\u8d77\u7684 \u00a0\u8fd9\u65f6\u5019\u70b9\u51fb\u67e5\u770b\u8be6\u60c5 \uff0c\u5148\u5b89\u88c5\u7f3a\u5c11\u7684\u4f9d\u8d56\u63d2\u4ef6\u5373\u53ef\u3002<\/p>\n<p>\u5bf9\u4e8e\u6211\u4eec\u7684\u90e8\u7f72.net\u9879\u76ee \uff0c\u7528\u5230\u7684\u4e3b\u8981\u63d2\u4ef6\u6709 MSBuild \uff08\u7f16\u8bd1.net\u9879\u76ee\uff09\uff0cGitLab(\u4ece\u6e90\u7801\u7ba1\u7406\u5668\u4e0a\u83b7\u53d6\u4ee3\u7801\u5e76\u7f16\u8bd1)\uff0cPublish Over FTP\u6216FTP publisher\uff08\u901a\u8fc7FTP\u628a\u751f\u6210\u7684\u9879\u76ee\u6587\u4ef6\u4f20\u9001\u5230\u76ee\u6807\u670d\u52a1\u5668\uff0c\u4f46\u662f\u9700\u8981\u76ee\u6807\u670d\u52a1\u5668\u7684FTP\u652f\u6301\uff0c\u540e\u9762\u5b9e\u9645\u6ca1\u6709\u91c7\u7528\u8fd9\u79cd\u65b9\u5f0f\uff09\uff0cPowerShell(\u505c\u6b62\\\u5f00\u542f\u8fdc\u7a0b\u670d\u52a1\u5668\u670d\u52a1\u3001\u7f51\u7ad9\u3001\u62f7\u8d1d\u6587\u4ef6\u7b49\u7528\u9014)\uff0c \u00a0 Copy Artifact Plugin(\u628a\u5176\u4ed6Job\u5de5\u4f5c\u533a\u7684\u6587\u4ef6\u62f7\u8d1d\u5230\u5f53\u524dJob)\u3002 \u9664\u6b64\u4e4b\u5916 \u00a0\u8fd8\u6709\u8bb8\u591a\u4e0b\u6e38\u4f9d\u8d56\u63d2\u4ef6 \u5982git \u7b49 \u00a0\u5c31\u4e0d\u4e00\u4e00\u5217\u51fa\u3002<\/p>\n<p>\u4e09\u3001\u90e8\u5206\u63d2\u4ef6\u7684\u5168\u5c40\u8bbe\u7f6e\uff1a<\/p>\n<p>\u7cfb\u7edf\u7ba1\u7406&#8211;&gt;\u7cfb\u7edf\u8bbe\u7f6e \u4e2d<\/p>\n<p>\u8fd9\u4e2a\u63d2\u4ef6\u662f\u7528FTP\u5411\u8fdc\u7a0b\u670d\u52a1\u5668\u62f7\u8d1d\u6587\u4ef6\/\u6587\u4ef6\u5939\u7528\u7684 \uff08\u9700\u8981\u8fdc\u7a0b\u670d\u52a1\u5668\u5f00\u542fFTP\u670d\u52a1\uff09\uff0c\u7531\u4e8e\u6211\u540e\u6765\u4f7f\u7528\u7684PowerShell \u65b9\u5f0f\uff0c\u6240\u4ee5\u8fd9\u4e2a\u65b9\u5f0f\u6682\u65f6\u6ca1\u6709\u7528\u5230\uff0c\u540e\u671f\u5907\u7528\u5427\u3002<\/p>\n<p>\u56db\u3001\u9879\u76ee\u914d\u7f6e\uff1a<\/p>\n<p>\u5176\u4e2d\u00a0Credentials \u662f\u8981\u7528\u00a0SSH Username with private key \u65b9\u5f0f\u914d\u7f6e\u7684\uff0c\u628a\u672c\u673a\u7684PRIVATE KEY\u586b\u4e0a\u5373\u53ef \u3010\u5176\u4ed6\u65b9\u5f0f\u6682\u65f6\u8fde\u4e0d\u4e0a\uff0c\u5f85\u7814\u7a76\u3011<\/p>\n<p>\u914d\u7f6eGitLab Hook \uff1a<\/p>\n<p>\u901a\u8fc7GitLab Hook \u00a0\u94a9\u5b50 \u00a0\u53ef\u4ee5\u5b9e\u73b0 \u00a0\u6709\u4ee3\u7801push\u5230\u6307\u5b9a\u5206\u652f\u81ea\u52a8\u6267\u884cJOB\u7684\u76ee\u7684\u3002<\/p>\n<p>\u9700\u8981\u5b89\u88c5Jenkins\u7684\u63d2\u4ef6\u6709\u00a0gitlab-hook\u00a0 \uff08\u4f9d\u8d56\u4e8eruby-runtime\uff09<\/p>\n<p>\u5b89\u88c5\u597d\u540e \u00a0 \u9700\u8981\u5206\u522b\u5728gitlab \u548cjenkins \u4e0a\u505a\u76f8\u5e94\u7684\u914d\u7f6e<\/p>\n<p>jenkins \u89e6\u53d1\u5668\u4e2d\u9009\u62e9gitlab hook \u00a0 \u00a0\u80fd\u770b\u5230\u56de\u8c03URL , \u9ad8\u7ea7\u9009\u9879 \u751f\u6210 Token\u3002 \u00a0 \u00a0 \u7136\u540e\u53bbgitlab \u5206\u522b\u628a \u56de\u8c03URL \u548cToken \u586b\u5165 webhooks\u8bbe\u7f6e\u754c\u9762 \u00a0\u3002<\/p>\n<p>\u65b0\u589e \u7136\u540e\u6d4b\u8bd5 \uff0c\u5982\u679c\u663e\u793a\u84dd\u8272200 \u00a0\u5219\u914d\u7f6e\u6210\u529f\uff01 \u00a0\u5177\u4f53\u6b65\u9aa4\u89c1\u4e0b\u56fe<\/p>\n<p>\u8fd9\u91cc\u6ca1\u4ec0\u4e48\u53ef\u8bf4\u7684 \u5177\u4f53\u7f16\u8bd1\u7684\u7ec6\u8282 \u53c2\u6570\u90fd\u5199\u5728 solution.msbuild \u6587\u4ef6\u91cc\u4e86 \uff0c\u6ce8\u610f\u8fd9\u4e2a\u6587\u4ef6\u4e5f\u8981\u4e0a\u4f20\u5230git \u3002 \u8fd9\u6587\u4ef6\u91cc\u4e3b\u8981\u505a\u4e86\u4e09\u4ef6\u4e8b<\/p>\n<p>\u5220\u9664\u539f\u751f\u6210\u76ee\u5f55<\/p>\n<p>\u5efa\u7acb\u65b0\u751f\u6210\u76ee\u5f55<\/p>\n<p>\u7f16\u8bd1\u751f\u6210\u9879\u76ee<\/p>\n<p>\u5f53\u7136\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u7684\u6d89\u53ca\u7684\u8fd9\u4e9b\u76ee\u5f55 \u90fd\u662f\u653e\u5728\u5de5\u4f5c\u7a7a\u95f4\u76ee\u5f55\u4e2d\u7684\u3002\u5de5\u4f5c\u7a7a\u95f4\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\uff1a Jenkins\\workspace\\JobName \u00a0\uff08Jenkins\u76ee\u5f55 \u5728\u5168\u5c40\u8bbe\u7f6e\u91cc\u9762\u53ef\u4ee5\u8bbe\u7f6e\uff09<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-20170703\u8865\u5145 \u00a0msbuild \u4e0d\u8c03\u7528\u811a\u672c\uff0c\u76f4\u63a5\u5199\u53c2\u6570&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>msbuild \u53ef\u4ee5\u76f4\u63a5\u8c03\u7528sln\u4ee5\u53cacsproj\u6587\u4ef6\u3002\u6240\u4ee5\u5982\u679c\u662f\u53d1\u5e03web\u9879\u76ee\u7684\u65f6\u5019\uff0c\u53ef\u4ee5msbuild \u540e\u9762\u76f4\u63a5\u8ddf\u8981\u53d1\u5e03web\u9879\u76ee\u7684csproj\u6587\u4ef6\u3002<\/p>\n<p>\u5982msbuild \u00a0Web.csproj<\/p>\n<p>\u5173\u4e8e\u540e\u9762\u7684\u53c2\u6570 \u00a0\u4f8b\u5982\uff1a<\/p>\n<p>\/t:ResolveReferences;Compile<br \/>\n\/t:_CopyWebApplication<br \/>\n\/p:Configuration=Release<br \/>\n\/p:WebProjectOutputDir=C:\/Software\/Jenkins\/workspace\/MESWebService\/Publish<br \/>\n\/p:OutputPath=C:\/Software\/Jenkins\/workspace\/MESWebService\/Publish\/bin<\/p>\n<p>\u8fd9\u662f\u53d1\u5e03Web\u9879\u76ee\u7684 \u4e00\u822c\u53c2\u6570\u5f62\u5f0f \u628a\u6700\u540e\u4e24\u884c \u00a0\u53d1\u5e03\u5730\u5740\u6362\u4e86\u5373\u53ef<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>\u8fd9\u6b65\u64cd\u4f5c \u662f\u628a\u751f\u6210\u7684\u9879\u76ee\u76ee\u5f55\u5b58\u6863\uff0c\u4ee5\u4fbf\u4e0b\u6e38Job\u8c03\u7528\u3002\u8fd9\u91cc\u7528\u5230\u4e86\u00a0Copy Artifact \u00a0\u63d2\u4ef6\u3002<\/p>\n<p>\u4e0b\u9762\u5c31\u662f\u7b2c\u4e8c\u4e2aJob\u4e86 \u00a0:<\/p>\n<p>\u8fd9\u4e24\u4e2a\u5730\u65b9 \u662f\u548c\u4e0a\u4e00\u4e2aJob\u8854\u63a5\u7684 \u5f53\u4e0a\u4e00\u4e2aJOB\u6267\u884c\u6210\u529f\u81ea\u52a8\u89e6\u53d1\uff0c\u628a\u751f\u6210\u6210\u529f\u7684\u53d1\u5e03\u76ee\u5f55\u62f7\u8d1d\u5230\u5f53\u524d\u5de5\u4f5c\u7a7a\u95f4<\/p>\n<p>\u6b64\u5904\u662f\u53e6\u4e00\u4e2a\u5173\u952e\uff0c\u5229\u7528PowerShell \u00a0\u5148\u505c\u6b62\u8fdc\u7a0b\u7f51\u7ad9\uff0c \u628a\u6587\u4ef6\u8986\u76d6\u8fc7\u53bb\uff0c\u518d\u542f\u52a8\u7f51\u7ad9\uff0c\u6700\u540e\u522b\u5fd8\u4e86\u91ca\u653e\u767b\u5f55Session .<\/p>\n<p>*****************20170628\u8865\u5145 \u53d1\u5e03\u9879\u76ee\u524d\u81ea\u52a8\u5907\u4efd************************************************************************<\/p>\n<p>\u601d\u8def\u662f\u4f7f\u7528PowerShell\u811a\u672c \u00a0\u628a\u5f53\u524d\u7684\u9879\u76ee\u6587\u4ef6\u5939 \u6574\u4e2a\u62f7\u8d1d\u5230\u5907\u4efd\u6587\u4ef6\u5939\u4e2d \uff0c\u5e76\u4ee5\u5f53\u524d\u65e5\u671f\u65f6\u95f4\u547d\u540d\u3002<\/p>\n<p>\u4e0a\u56fe\u4e2d\u7684Powershell\u547d\u4ee4\u505a\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n<p>Invoke-Command -Session $session -ScriptBlock{<br \/>\nc:\\windows\\System32\\inetsrv\\appcmd stop site &#8220;WebService&#8221;<br \/>\nE:\\WebServiceBackUp\\BackUpDir.ps1 \u00a0 \u00a0 #\u505c\u6389\u7f51\u7ad9\u540e \u00a0\u6267\u884c\u5907\u4efd\u811a\u672c\uff08\u5907\u4efd\u811a\u672c\u5df2\u5199\u597d \u00a0\u653e\u7f6e\u5728\u7f51\u7ad9\u90e8\u7f72\u670d\u52a1\u5668\u4e0a\uff09<br \/>\n}<\/p>\n<p>\u5907\u4efd\u811a\u672c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<p>#\u6e90\u76ee\u5f55<br \/>\n$pathFrom = &#8220;E:\\WebService&#8221;;<br \/>\n#\u76ee\u6807\u76ee\u5f55<br \/>\n$pathTo = &#8220;E:\\WebServiceBackUp\\bak&#8221;+(Get-Date -Format &#8216;yyyyMMddHHmmss&#8217;);<br \/>\nwrite-host(&#8220;SourcePath is: &#8221; + $pathFrom);<br \/>\nwrite-host(&#8220;TargetPath is: &#8221; + $pathTo);<br \/>\n#\u521b\u5efa\u76ee\u6807\u76ee\u5f55<br \/>\nmkdir -Pa $pathTo;<br \/>\nif (!(Test-path -path $pathFrom)){<br \/>\nwrite-host(&#8220;SourcePath is not exist!&#8221;);<br \/>\nexit -1;<br \/>\n}<\/p>\n<p>$pathCopyTo = &#8220;&#8221;;<br \/>\n$pathFromLen = $pathFrom.Length;<br \/>\n$LenGap = 0;<br \/>\n$LenGap2 = 0;<\/p>\n<p>ls -r $pathFrom | Foreach-Object{<br \/>\n$lenGap = $_.FullName.Length &#8211; $pathFromLen &#8211; $_.Name.Length &#8211; 1;<br \/>\n$pathCopyTo = $PathTo + $_.FullName.Substring($pathFromLen, $lenGap);<\/p>\n<p>write-host(&#8220;Copy &#8221; + $_.FullName + &#8221; to &#8221; + $pathCopyTo);<br \/>\nif(!(Test-path -path $pathCopyTo)){<br \/>\nmkdir -Pa $pathCopyTo;<br \/>\n}<br \/>\ncopy-item $_.FullName $pathCopyTo -Force;<br \/>\n}<br \/>\nexit 0;<br \/>\n\u4f7f\u7528\u7684\u65f6\u5019 \u53ea\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u628a\u6e90\u76ee\u5f55\u548c\u76ee\u6807\u76ee\u5f55\u4fee\u6539\u4e86\u5c31\u597d\uff08\u4e5f\u53ef\u4ee5\u5199\u6210\u53c2\u6570\u7684\u5f62\u5f0f\u5728\u8c03\u7528\u811a\u672c\u7684\u65f6\u5019\u4f20\u8fdb\u76ee\u5f55\uff09<\/p>\n<p>\u6ce8\uff1a\u90e8\u7f72\u9879\u76ee\u7684\u670d\u52a1\u5668 \u521d\u6b21\u8fd0\u884cps1\u811a\u672c\u7684\u65f6\u5019 \u51fa\u73b0\u201c\u65e0\u6cd5\u52a0\u8f7d\u6587\u4ef6 ******.ps1\uff0c\u56e0\u4e3a\u5728\u6b64\u7cfb\u7edf\u4e2d\u7981\u6b62\u6267\u884c\u811a\u672c\u201d \u7684\u9519\u8bef \uff0c\u539f\u56e0\u662f\u9ed8\u8ba4\u8bbe\u7f6e\u662f\u7981\u6b62\u8fd0\u884c<\/p>\n<p>\u811a\u672c\u7684\uff0c\u9700\u8981\u624b\u52a8\u6253\u5f00 \uff0c\u65b9\u6cd5\u662f\u5728PowerShell \u00a0\u4e2d \u8f93\u5165\u547d\u4ee4\u00a0\u00a0set-executionpolicy remotesigned \u00a0\u7136\u540e\u518d\u6309\u63d0\u793a\u8f93\u5165Y \u5373\u53ef<\/p>\n<p>********************************************20170629\u8865\u5145 \u00a0 \u4e00\u952e\u8fd8\u539f\u5230\u6700\u8fd1\u5907\u4efd\u7248\u672c*************************************************************************<\/p>\n<p>\u6839\u636e\u4e0a\u4e00\u6b65\u64cd\u4f5c \uff0c\u5728\u53d1\u5e03\u65b0\u7248\u672c\u524d\uff0c\u5df2\u7ecf\u628a\u9879\u76ee\u90fd\u5907\u4efd\u597d\u4e86 \u3002\u4e0b\u9762\u7684\u601d\u8def\u4f9d\u7136\u662f\u5229\u7528Jenkins\u65b0\u5efa\u4e00\u4e2aJob\u53bb\u76f4\u63a5\u8c03\u7528\u670d\u52a1\u5668\u4e0a\u5199\u597d\u7684powershell\u811a\u672c\u3002<\/p>\n<p>Jenkins\u914d\u7f6e\uff1a<\/p>\n<p>$pass=ConvertTo-SecureString -String &#8216;\u5bc6\u7801&#8217; -AsPlainText -Force<br \/>\n$cre=New-Object System.Management.Automation.PSCredential(&#8216;\u7528\u6237\u540d&#8217;, $pass)<br \/>\n$session=New-PSSession -ComputerName \u670d\u52a1\u5668IP -Credential $cre<\/p>\n<p>Invoke-Command -Session $session -ScriptBlock{<br \/>\nc:\\windows\\System32\\inetsrv\\appcmd stop site &#8220;\u7f51\u7ad9\u540d&#8221;<br \/>\nE:\\WebServiceBackUp\\RevertVersion.ps1 #\u8981\u6267\u884c\u7684\u5173\u952e\u811a\u672c<br \/>\nc:\\windows\\System32\\inetsrv\\appcmd start site &#8220;\u7f51\u7ad9\u540d&#8221;<br \/>\n}<br \/>\nRemove-PSSession -Id $session.Id<br \/>\nPowerShell\u811a\u672c\uff1a<\/p>\n<p>$pathFrom = &#8220;E:\\WebServiceBackUp&#8221;;<br \/>\n$pathTo = &#8220;E:\\WebService&#8221;;<br \/>\n#\u83b7\u53d6\u6700\u65b0\u7684\u5907\u4efd\u6587\u4ef6\u76ee\u5f55<br \/>\n$pathFrom= $pathFrom+&#8221;\\&#8221;+(ls &#8220;e:\\WebServiceBackUp\\&#8221; |?{$_.Mode -eq &#8220;d&#8212;-&#8220;}|sort -Descending LastWriteTime)[0].Name; #\u901a\u7528<br \/>\n#$pathFrom= $pathFrom+&#8221;\\&#8221;+(ls -dir -r $pathFrom | sort -Descending LastWriteTime)[0].Name; #\u4ec5ps5\u652f\u6301 \u670d\u52a1\u5668\u4e0a\u7248\u672c\u592a\u4f4e\u3002\u3002<br \/>\nwrite-host(&#8220;Source:&#8221;+$pathFrom);<br \/>\nwrite-host(&#8220;To&#8221;+$pathTo);<br \/>\n#\u6e05\u7a7a\u9879\u76ee\u6587\u4ef6\u5939<br \/>\nRemove-Item ($pathTo+&#8221;\\*&#8221;) -recurse<br \/>\nwrite-host(&#8220;Clear Finish!&#8221;);<br \/>\n#\u62f7\u8d1d\u6587\u4ef6<br \/>\n$pathCopyTo = &#8220;&#8221;;<br \/>\n$pathFromLen = $pathFrom.Length;<br \/>\n$LenGap = 0;<br \/>\nls -r $pathfrom | foreach-object{<br \/>\n$lengap = $_.fullname.length &#8211; $pathfromlen &#8211; $_.name.length &#8211; 1;<br \/>\n$pathcopyto = $pathto + $_.fullname.substring($pathfromlen, $lengap);<br \/>\nif(!(test-path -path $pathcopyto)){<br \/>\nmkdir -pa $pathcopyto;<br \/>\n}<br \/>\ncopy-item $_.fullname $pathcopyto -force;<br \/>\n}<br \/>\nwrite-host(&#8220;Revert Finish!&#8221;);<br \/>\nexit 0;<br \/>\n\u4ee5\u4e0a\u811a\u672c \u00a0\u5728\u5907\u4efd\u6587\u4ef6\u5939\u4e2d\u7b5b\u9009\u5907\u4efd\u7684\u65f6\u5019 \u00a0\u662f\u6309\u4fee\u6539\u65f6\u95f4\u7b5b\u9009\u6700\u8fd1\u7684\u6587\u4ef6\u5939 \uff0c\u8fd8\u6709\u4e00\u4e2a\u601d\u8def \uff0c\u53ef\u4ee5\u6309\u5907\u4efd\u6587\u4ef6\u5939\u547d\u540d\u683c\u5f0f \u7528\u6b63\u5219\u8fc7\u6ee4\u51fa\u6240\u6709\u5907\u4efd\u6587\u4ef6\u5939\uff0c\u518d\u6309\u6587\u4ef6\u5939<br \/>\n\u540d\u5b57\u964d\u5e8f\u6392\u5217\u4e5f\u80fd\u53d6\u51fa\u6700\u8fd1\u7684\u6587\u4ef6\u5939\u540d\u5b57\u3002<\/p>\n<p>*******************************************************************************************************************************************************************<\/p>\n<p>\u81f3\u6b64 \uff0c\u4efb\u52a1\u7684\u914d\u7f6e\u57fa\u672c\u5b8c\u6210\u3002\u6267\u884c\u7684\u65f6\u5019 \u53ea\u9700\u6253\u5f00\u7b2c\u4e00\u4e2aJob \u00a0\u70b9\u51fb\u7acb\u5373\u6784\u5efa\uff0c\u5373\u53ef\u81ea\u52a8\u5b8c\u6210\u9879\u76ee\u4eceGitLab\u4e0a\u62c9\u53d6\u6307\u5b9a\u5206\u652f\u7684\u6700\u65b0\u4ee3\u7801\uff0c\u7f16\u8bd1\u53d1\u5e03\uff0c\u505c\u7f51\u7ad9\uff0c<\/p>\n<p>\u62f7\u8d1d\u8986\u76d6\u6587\u4ef6\uff0c\u542f\u52a8\u7f51\u7ad9\u7b49\u4e00\u7cfb\u5217\u52a8\u4f5c\uff0c\u5f53\u7136 \uff0c\u540e\u671f\u5982\u6709\u9700\u8981 \uff0c\u53ef\u4ee5\u8bbe\u7f6e\u8f6e\u8be2\u65b9\u5f0f\uff0c\u5728\u6307\u5b9a\u65f6\u95f4\u81ea\u52a8\u53d1\u5e03\u9879\u76ee\uff0c\u6216\u8005\u4f7f\u7528Hook \u94a9\u5b50\u65b9\u5f0f\uff0c\u5f53\u6709\u4ee3\u7801\u63d0\u4ea4\u81ea\u52a8<\/p>\n<p>\u53d1\u5e03\u9879\u76ee\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0b\u9762\u8bf4\u4e00\u4e0b.net\u9879\u76ee\u7684\u7f16\u8bd1\u73af\u5883\u3001MSBuild\u73af\u5883\u914d\u7f6e\u3001PowerShell\u7684\u8bbe\u7f6e\u7b49\u6587\u4ef6\uff1a<\/p>\n<p>MSBuild \u00a0\u547d\u4ee4\u7684\u4f7f\u7528\uff0c\u8981\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u628a.net framework \u7684\u76ee\u5f55\uff08\u5982C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\uff09\u5199\u8fdbPath\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<p>\u7f16\u8bd1\u8981\u6709\u73af\u5883\uff0c\u800c\u4e00\u822c\u670d\u52a1\u5668\u662f\u6ca1\u6709\u5f00\u53d1\u73af\u5883\u7684\uff0c\u8fd9\u65f6\u5019\u4e00\u822c\u6709\u4e24\u4e2a\u9009\u62e9\uff0c\u5b89\u88c5Visual Studio \uff082012\u4ee5\u4e0a\uff0c\u5efa\u8bae\u8fd9\u79cd\u540e\u671f\u9ebb\u70e6\u53ef\u80fd\u4f1a\u5c11\u4e00\u70b9\uff09\uff0c\u8981\u4e0d\u5c31<\/p>\n<p>\u5b89\u88c5 Windows SDK \uff0c\u8fd9\u91cc\u9762\u6709\u7f16\u8bd1\u6240\u4f9d\u8d56\u7684\u4e1c\u897f\u3002\u8fd9\u65f6\u5019 \u53ef\u4ee5\u5c1d\u8bd5\u7f16\u8bd1\u4e86 \uff0c\u4e00\u822c\u6d4b\u8bd5\u7f16\u8bd1\u73af\u5883\u7684\u65f6\u5019\u5728\u672c\u5730\u76f4\u63a5\u7528msbuild \u547d\u4ee4\u5373\u53ef\uff0c\u4e0d\u7528\u4e0aJenkins.<\/p>\n<p>\u8fd9\u65f6\u5019\uff0c\u53ef\u80fd\u4f1a\u63d0\u793a\u7f3a\u5c11\u5404\u79cd\u6587\u4ef6\uff0c\u6839\u636e\u9519\u8bef\u63d0\u793a\uff0c\u4ece\u5f00\u53d1\u673a\u4e0a\u62f7\u8d1d\u8fc7\u53bb\u5373\u53ef\uff0c\u6ce8\u610f\uff0c\u4e0a\u4f20gitlab\u65f6 \u00a0packages\u5305\uff0c\u5404\u79cd\u5f15\u7528dll\u4e5f\u8981\u4e0a\u4f20\uff0c\u4e0d\u7136\u540e\u9762\u62c9\u53d6\u4ee3\u7801\u5230\u5de5\u4f5c\u533a\u7f16\u8bd1\u7684\u65f6\u5019<\/p>\n<p>\u4f1a\u5c11\u8fd9\u4e9b\u6587\u4ef6.\u3002<\/p>\n<p>\u6ce8\u610f\uff0c\u7f16\u8bd1\u65f6\u5019\uff0c\u62a5\u9519\u53ef\u80fd\u4f1a\u8ddfC:\\Program Files (x86)\\MSBuild \u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u6709\u5173\uff0c\u8fd9\u65f6\u5019\u6839\u636e\u63d0\u793a\uff0c\u628a\u76f8\u5e94\u7684\u76ee\u5f55\u4ece\u5f00\u53d1\u673a\u62f7\u8d1d\u8fc7\u53bb\uff0c\u5b9e\u5728\u4e0d\u884c \u628a\u51fa\u9519\u76ee\u5f55<\/p>\n<p>\u5220\u9664\u4f1a\u6709\u5947\u6548\uff0c\u5b83\u4f1a\u5bfb\u6c42\u5176\u4ed6\u76ee\u5f55\uff0c\u5176\u4ed6\u76ee\u5f55\u73af\u5883\u4e5f\u8bb8\u662f\u5b8c\u597d\u7684\u3002<\/p>\n<p>\u6211\u64cd\u4f5c\u7684\u73af\u5883\u662fWindows Server 2008 R2 \u00a0 \uff0c\u4f46\u662fPowerShell\u7684\u5411\u8fdc\u7a0b\u670d\u52a1\u5668\u62f7\u8d1d\u6587\u4ef6\u7684\u547d\u4ee4\u53ea\u80fdPowerShell5\u624d\u652f\u6301\uff0cPowerShell5\u662f<\/p>\n<p>windows management framework5\u7684\u4e00\u90e8\u5206\uff0cWMF5\u53c8\u4f9d\u8d56\u4e8e\u00a0Windows Server 2008 R2 SP1 \u548c.net framework4.5\uff0c\u6240\u4ee5 \u00a0\u90fd\u8981\u5b89\u88c5\u4e0a\u3002<\/p>\n<p>\u90fd\u88c5\u597d\u540e \u00a0\u6253\u5f00PowerShell \u00a0\u00a0$PSVersionTable.PSVersion\u547d\u4ee4\u67e5\u770b\u7248\u672c \u00a0\u786e\u8ba4\u662f\u4e0d\u662f5.<\/p>\n<p>\u4f7f\u7528PowerShell\u8fde\u63a5\u8fdc\u7a0b\u673a\u5668 \u9700\u8981\u5148\u6dfb\u52a0\u4fe1\u4efb\u5217\u8868 \u547d\u4ee4<\/p>\n<p>winrm set winrm\/config\/client &#8216;@{TrustedHosts=&#8221;xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx&#8221;}&#8217;<\/p>\n<p>(\u6ce8\u610f\u662f\u8bbe\u7f6eTrustedHosts\u4e0d\u662f\u6dfb\u52a0\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2aTrustedHosts\uff0c\u7528\u9017\u53f7\u5206\u5f00)\u597d\u50cf\u662f\u5ba2\u6237\u7aef\uff08\u6e90\u670d\u52a1\u5668\uff09\u7528\u8bbe\u7f6e \u670d\u52a1\u7aef\uff08\u76ee\u6807\u670d\u52a1\u5668\uff09\u4e0d\u7528<\/p>\n<p>\u7136\u540e\u521d\u59cb\u5316\u914d\u7f6e\u00a0winrm quickconfig \u6839\u636e\u63d0\u793a \u8f93\u5165\u4e00\u5230\u4e24\u6b21&#8217;yes&#8217; \u5373\u53ef\u3002<\/p>\n<p>[\u67e5\u770b\u5df2\u914d\u7f6e\u7684TrustedHosts:Get-Item\u00a0WSMan:\\localhost\\Client\\TrustedHosts\u00a0|\u00a0Select-Object\u00a0Value]<\/p>\n<p>\u6700\u540e \u8d34\u4e0b solution.msbuild\u6587\u4ef6 \u3010\u5176\u5b9e\u4e0d\u7528\u8fd9\u4e2a\u6587\u4ef6 \uff0c\u76f4\u63a5 \u7f16\u8bd1csproj \u6216sln\u6587\u4ef6\u540e\u9762\u52a0\u53c2\u6570\u4e5f\u53ef\u4ee5\uff0c\u53ea\u662f\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u589e\u52a0\u4e86\u5220\u9664\\\u65b0\u5efa\u76ee\u5f55\u7b49\u5176\u4ed6\u529f\u80fd\u3011<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;Project xmlns=&#8221;http:\/\/schemas.microsoft.com\/developer\/msbuild\/2003&#8243; DefaultTargets=&#8221;Compile&#8221;&gt;<br \/>\n&lt;ItemGroup&gt;<br \/>\n&lt;BuildArtifactsDir Include=&#8221;BuildArtifacts\\&#8221; \/&gt;<br \/>\n&lt;SolutionFile Include=&#8221;trunk\\MKCurtain.sln&#8221; \/&gt;<br \/>\n&lt;\/ItemGroup&gt;<\/p>\n<p>&lt;PropertyGroup&gt;<br \/>\n&lt;Configuration Condition=&#8221; &#8216;$(Configuration)&#8217; == &#8221; &#8220;&gt;Release&lt;\/Configuration&gt;<br \/>\n&lt;BuildPlatform Condition=&#8221; &#8216;$(BuildPlatform)&#8217; == &#8221; &#8220;&gt;Any CPU&lt;\/BuildPlatform&gt;<br \/>\n&lt;\/PropertyGroup&gt;<\/p>\n<p>&lt;Target Name=&#8221;Compile&#8221; DependsOnTargets=&#8221;Init&#8221;&gt;<br \/>\n&lt;MSBuild Projects=&#8221;@(SolutionFile)&#8221; Targets=&#8221;Rebuild&#8221;<br \/>\nProperties=&#8221;OutDir=%(BuildArtifactsDir.FullPath);Configuration=$(Configuration);Platform=$(BuildPlatform)&#8221; \/&gt;<br \/>\n&lt;\/Target&gt;<\/p>\n<p>&lt;Target Name=&#8221;Init&#8221; DependsOnTargets=&#8221;Clean&#8221;&gt;<br \/>\n&lt;MakeDir Directories=&#8221;@(BuildArtifactsDir)&#8221; \/&gt;<br \/>\n&lt;\/Target&gt;<\/p>\n<p>&lt;Target Name=&#8221;Clean&#8221;&gt;<br \/>\n&lt;RemoveDir Directories=&#8221;@(BuildArtifactsDir)&#8221; \/&gt;<br \/>\n&lt;\/Target&gt;<\/p>\n<p>&lt;\/Project&gt;<\/p>\n<p>\u53c2\u8003\u6587\u6863\uff1ahttp:\/\/blog.csdn.net\/dj0379\/article\/details\/52389454<\/p>\n<p>http:\/\/blog.csdn.net\/wangmuming\/article\/details\/22925671<\/p>\n<p>http:\/\/www.cnblogs.com\/scheshan\/p\/5849704.html<\/p>\n<p>https:\/\/www.cnblogs.com\/v5captain\/articles\/6480708.html \u00a0\u5907\u4efd\u6062\u590d<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\u4f5c\u8005\uff1azy0421911<br \/>\n\u6765\u6e90\uff1aCSDN<br \/>\n\u539f\u6587\uff1ahttps:\/\/blog.csdn.net\/zy0421911\/article\/details\/72621012<br \/>\n\u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3a\u535a\u4e3b\u539f\u521b\u6587\u7ae0\uff0c\u8f6c\u8f7d\u8bf7\u9644\u4e0a\u535a\u6587\u94fe\u63a5\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u4e0b\u8f7d\u5b89\u88c5Jenkins \u00a0: \u5b98\u7f51\u5730\u5740\u00a0https:\/\/jenkins.io\/index.html \u00a0 \u5b89\u88c5\u6ca1\u4ec0\u4e48\u7279\u6b8a\u7684 \u5e38\u89c4\u5b89\u88c5\u5373\u53ef\u3002\u5b89\u88c5\u540e\u9ed8\u8ba4\u5360\u75288080\u7aef\u53e3\u3002\u53ef\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u3002 \u4e8c\u3001\u914d\u7f6e\uff1a \u9996\u6b21\u8bbf\u95ee\uff0c\u4f1a\u63d0\u793a\u5b89\u88c5\u63d2\u4ef6\uff0c\u5982\u679c\u5b89\u88c5Jenkins\u7684\u670d\u52a1\u5668\u53ef\u4ee5\u8054\u7f51\uff0c\u9009\u62e9\u9700\u8981\u7684\u5b89\u88c5\u5373\u53ef\u3002\u4f46\u5982\u679c\u4e0d\u80fd\u8054\u7f51\uff0c\u8fd9\u91cc\u4e0d\u80fd\u9009\u62e9\u4efb\u4f55\u63d2\u4ef6\u5b89\u88c5\uff0c\u5426\u5219\u4f1a\u62a5\u9519\uff08\u540e\u9762\u4f1a\u81ea\u5df1\u4e0b\u8f7d\u63d2\u4ef6\u5305\u901a\u8fc7\u4e0a\u4f20\u7684\u65b9\u5f0f\u8fdb\u884c\u5b89\u88c5\uff09\u3002 \u7136\u540e\u5c31\u662f\u6ce8\u518c\u4e00\u4e2a\u7ba1\u7406\u5458\u8d26\u53f7 \u5373\u53ef\u767b\u5f55\u8fdb\u884c\u914d\u7f6e\u4e86\u3002 \u79bb\u7ebf\u5b89\u88c5\u63d2\u4ef6\uff1a \u63d2\u4ef6\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/updates.jenkins-ci.org\/download\/plugins\/ \u4e0b\u8f7d\u597d\u5bf9\u5e94\u7684\u63d2\u4ef6\uff08\u4e00\u822c\u6700\u65b0\u7248\u5c31\u884c,\u6ce8\u610f\u63d2\u4ef6\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u8981\u4e0b\u8f7d\u6574\u4e2a\u4f9d\u8d56\u6811\u7684\u6240\u6709\u4e0b\u6e38\u63d2\u4ef6\u5e76\u4ece\u4e0b\u5f80\u4e0a\u5b89\u88c5\uff0c\u5426\u5219\u4f1a\u51fa\u9519\uff0c\u4e5f\u53ef\u4ee5\u6839\u636e\u51fa\u9519\u63d0\u793a\u4f9d\u6b21\u4e0b\u8f7d\u7f3a\u5c11\u7684\u63d2\u4ef6\uff09\u3002 \u7cfb\u7edf\u7ba1\u7406&#8211;&gt;\u7ba1\u7406\u63d2\u4ef6&#8211;&gt;\u9ad8\u7ea7&#8211;&gt;\u4e0a\u4f20\u63d2\u4ef6&#8211;&gt;\u9009\u62e9\u6587\u4ef6&#8211;&gt;\u9009\u62e9\u521a\u624d\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff08\u4e00\u6b21\u53ea\u80fd\u9009\u62e9\u4e00\u4e2a\uff0c\u4e00\u822c\u4e3ahpi\u683c\u5f0f\uff09\uff0c\u7136\u540e\u4f1a\u81ea\u52a8\u8fdb\u884c\u5b89\u88c5\u3002\u5982\u679c\u5b89\u88c5\u5931\u8d25\uff0c\u4e00\u822c\u662f\u7531\u4e8e\u7f3a\u5c11\u4f9d\u8d56\u63d2\u4ef6\u5f15\u8d77\u7684 \u00a0\u8fd9\u65f6\u5019\u70b9\u51fb\u67e5\u770b\u8be6\u60c5 \uff0c\u5148\u5b89\u88c5\u7f3a\u5c11\u7684\u4f9d\u8d56\u63d2\u4ef6\u5373\u53ef\u3002 \u5bf9\u4e8e\u6211\u4eec\u7684\u90e8\u7f72.net\u9879\u76ee \uff0c\u7528\u5230\u7684\u4e3b\u8981\u63d2\u4ef6\u6709 MSBuild \uff08\u7f16\u8bd1.net\u9879\u76ee\uff09\uff0cGitLab(\u4ece\u6e90\u7801\u7ba1\u7406\u5668\u4e0a\u83b7\u53d6\u4ee3\u7801\u5e76\u7f16\u8bd1)\uff0cPublish [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1179","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/1179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1179"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/1179\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}