点击"新建任务"创建一个自用风格的项目
点击"源码管理",选择 git
系统管理 --> Global Tool Configuration<为访问git服务添加认证-----------------上图 Credential 中的 add>
配置deploy-key
如下配置,jenkins服务器上root用户生成密钥对
https://www.cnblogs.com/guanyf/p/10600458.html ------>最好都配置上后续需要配置Publish over SSH时可以用到
配置jenkins的认证,这里应该输入私钥
复制jenkins拉取git代码服务器root的私钥
[root@dev-cui-06 .ssh]# pwd /root/.ssh [root@dev-cui-06 .ssh]# cat id_rsa -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEArkUnNKlapSudZdVLvbQTJErl8KqH6jtoA8bgvmgQ6xL3JpPV PuoMqx6SilBI2idN1BxqZbVC47gyAbIUm6S+HFyt1IkmtLr7dT7ZEDq/WkRJBxAz FV/TZff9N0zTcLOlOw+zR5ivh160Pyw3R1JoEl35CpeLlRk2p47ag8EGEaDOEhdz JDwAUKwG1BZe4WH7V3jEJ94v60W0YTpd6X7QhrgUodhrPrYJLOZ44fV5BEHzolN3 w9U8ti2rQ3UmPjnsA6R3e13/KcQnNnyhr7Ry5g2wOR9wZYkiyTxbOqu6JwbhbsHx 4itnLHhUuTFSkRlk4xEDOSsAQtWx0rPAumXaywIDAQABAoIBAFlxyuafiZO+6AFN UZujYjO9cXltvWa+aOuPVujDdvOAf3PAarHo5OmrPmFZRZsakzqr/vwG5bcFYj02 jpc4Hg9mjh3I6yHV2pxZzoUi8fW9mJHUgbOVxGXQu5l3iAqPWd4Pd9/mgSkEtZS6 +ABWTm4m51zFXXIAR+oGSydWmevPeEvhnbTb7WVyqmih1LnCU8SSbzXd+2f0LgHa 0GKJMPb5/I2+HSU6KV8pYs3FlOl/oWkx6EgEQcL4H2stHYF6u/zutPYwBljyhREb D9quHwgj6ZCeSc680a0bUY/3DUx15RaH+wIt0I6cGWBdup/fK+y/whG83Zxm0BLT NwoRNkECgYEA6B9by5KiP/shgikl5yzWYUNHJrsuR8wPgq7a98JLv6XjwRh9eqDn zcDLuS6QcyhbBQsmFZtQSCwFiSZzuGKLfzfXawS5LW66B7xJa+omT1gZjM1vZS9G ug13a4NAdQlDcMZbINlVkEAvE7VI1ZDfCIsb9fJO7fRiVp7i1+Wsw2sCgYEAwDJU E5dH62KETSku6Q/IFmJ5wCB82D0roX1V1KJvQzLdelhr0jtnqoz/6AFyWgB9cuc/ JpUie4VPRZ9VjWCCLEpmLRVlE2si24ZI6Iplz+lKKfodY/9vXLd/7tjBtb4ccVET iVkym6PpTH0Vmrk8uqu4/1plkCtsUBIdI5NWfiECgYEAmSrgGrOWhpuC3+2hCitn BuUrFR6cilnXvkb9TFGURFEFuYwceIemjflzNK3KOYLelLRnnAhRcF5EBN0vrPKx 0++YIREL1DPlY2dWF3R5dQ/QRD3nDKCmjeyG6ZXBObk0HD13MnTW5gnERr/v4KTo 1y1b9O3AMXp6TWgojYgLeSMCgYEAscbb1jM8pxG9ZtINPi8G2Q3FqF1knXAXh4yz c7e8SuAl1SEsuo2QWkWKAEQ2TeHeKAaWd03DU5X/uVqke90lC2rWECWWFNwopf4U OmSpwCL+Is3jmbeQfqaNg5SjuURccsSX2ZfUI/r9tW6OKUvmTJTCzhADmdNQoM/g fCOxAYECgYBLVMnkUQoKeQbV9KutpOAMSfL00SM6seEkgX4LnbgLPSAyx7oiVJFS leTT4vd6X5mED1eRHT5BTSDuBFwPcGefCSli4gvzuQkpkcezQPCDb0pFp/IpGzOl O7ez0BM0bZFeqYaxWNovHbxZakufPfa5l9SQy1FqbNwFhvKJAmzo4A== -----END RSA PRIVATE KEY----- [root@dev-cui-06 .ssh]#
添加描述,点击OK
继续编辑配置
这样就不报错了,下面还可以指定从哪个分支拉取,默认从master拉取,有些公司使用release分支
点击立即构建,查看控制台,可以看到构建的详细输出