1.1 jenkns 界面介绍(了解)
1.1.1 新建:进入后为新建项目等
1.1.1 用户:
1.1.1 任务历史:
以后项目构建后会在这里详细显示
不重要的就略过了
1.1.1 系统管理(重要)
其中 Global Tool Configuration 全局管理 ,管理插件用的最多
下面是插件管理
1.1.1 My Views 我的视图
里面为你创建的项目
1.1 创建一个新的工程
1.2 新建Job
下面开始第一个功能创建一个新的Job,选择新建
1.1 填写项目
进入后项目名称自定义、选择构建一个自由风格的软件项目,最后选择OK
1.1 输入项目名称和描述
1.1 源码管理选择git
备注:选择git 里面填写的是gitlab 项目地址、备注:我这边用的是gitlab。
jenkins 就是插件牛,如果不显示Git 或者你要用svn 直接到系统管理—插件管理—下载git等插件,记得安装完插件要重启jenkins。
输入后报错验证失败解决方法:
登录到Gitlab 中选择自己的项目,选择从创建部署key
其中备注为:项目名称+用户+IP 下面的是 公钥 jenkins主机的用户root(具体方法如下) 使jenkins 可以访问gitlab
1.1.1 创建key(在Jenkins 主机)
[root@jenkins ROOT]# ssh-keygen -t rsa #一直回车就可以 Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. #访问地址记住 Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 3b:4e:42:69:4c:0b:37:75:15:b2:c5:ad:15:3d:c8:72 root@jenkins The key's randomart image is: +--[ RSA 2048]----+ | . oo=ooo | | . . =.Eo..| | . + . oo .| | = + . | | * S | | o . | | . + | | + . | | . | +-----------------+ [root@jenkins empty]# cd /root/.ssh/ #查看公钥 [root@jenkins .ssh]# cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1AuQ/8w421a5+TerB8Mw7o0xCar218p3g927DMpul8tJfJdX1WXQiy/jCY19qY00fL4j6c6kRMtXBZWjrZildNyiUL5DRGpmwDpY3Vycrt4QG6Y73MXZmw7qSWL1cSsX7BSOlHikb5p+7ioIcgI0ViNVbmRAyCISrkT6E17nSl/vVDps5BUBfKjRymDcVvgHH4IDgTH9XuFPjbh5Vs9rksImDqRRYjkPCsKs+GqaQDwsyLq4dLyplZahFbi7fdnenQOj2PFWRQyhTrfXpLuIbUSQuxBXd/vLPu2wls2FL729N0yO202jOp1/r+zXDoglbLF4Wo/fYXTGFBYMNnho8w== root@jenkins
3.6.2 克隆项目验证(在Jenkins 主机)
[root@jenkins tools]# git clone git@172.16.1.55:web/web-demo.git Initialized empty Git repository in /home/yunwei/tools/web-demo/.git/ The authenticity of host '172.16.1.55 (172.16.1.55)' can't be established. RSA key fingerprint is d3:1f:d7:60:56:6c:4e:f0:90:5a:bf:83:ad:e7:93:77. Are you sure you want to continue connecting (yes/no)? yes #输入yes Warning: Permanently added '172.16.1.55' (RSA) to the list of known hosts. remote: Counting objects: 19, done. remote: Compressing objects: 100% (11/11), done. remote: Total 19 (delta 4), reused 0 (delta 0) Receiving objects: 100% (19/19), done. Resolving deltas: 100% (4/4), done. [root@jenkins tools]# ls apache-maven-3.5.0-bin.tar.gz java-1-8.sh web-demo apache-tomcat-8.0.27.tar.gz jdk-8u60-linux-x64.tar.gz
3.6.3 在Jenkins 上操作
选择一个认证 这里选择SSH Username with private key
选择jenkins 主机 中的私钥 用户为root
[root@jenkins ~]# cd .ssh/ [root@jenkins .ssh]# ls id_rsa id_rsa.pub known_hosts [root@jenkins .ssh]# ls -l 总用量 12 -rw------- 1 root root 1679 5月 22 22:46 id_rsa -rw-r--r-- 1 root root 394 5月 22 22:46 id_rsa.pub -rw-r--r-- 1 root root 786 7月 31 03:19 known_hosts [root@jenkins .ssh]# cat id_rsa -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA1AuQ/8w421a5+TerB8Mw7o0xCar218p3g927DMpul8tJfJdX 1WXQiy/jCY19qY00fL4j6c6kRMtXBZWjrZildNyiUL5DRGpmwDpY3Vycrt4QG6Y7 3MXZmw7qSWL1cSsX7BSOlHikb5p+7ioIcgI0ViNVbmRAyCISr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6muAL3Qr5fRytds8obHCKGR RnK+OvIkL2rsLsB/2C3nFSHXBtr0sFruJyuEQGlxT+aGB4Xpdww3YaOhwFeQ4wyL 1XpKD/74V9iUkL9TLrPpfYu3LT7EoY9xlqLZbbqA+omQC2Cgxn9WkxcmYYsf6TLf d1olgwKBgQCFf7qB7s2PTi4g9xNmcD0GZ39O3W9Z8F4+OAQ/OMSWD77OXcxfS0nN 4Kp5m9r+O+vX0i1myY2VE5KoL5CzxPos0W+sVDUKHfRUuuRpi2lDER+ALe1eXaBS gXFLIJW7Q0pJQOlvK2Nu/AFLFk61wqjRPoxAjE1vpf6F8vdwP06i0Q== -----END RSA PRIVATE KEY-----
Credentials 中选择创建的用户和备注,最后Add 添加。
1.1.1 源码管理
在源码管理中选择Git 在Credentals 中选择刚才Add 添加的用户(显示包括刚才写的备注信息)
设置Branch Specifier (blank for ‘any’) 默认不管(如果有git 有分支设置分支名称。)
源码库浏览器设置中注意:URL为gitlab项目http地址 Version 只能小数点两位
1.1 gitlab http 查看和gitlab 版本号查看
gitlab 版本号查询、 [root@gitlab ~]# rpm -qa|grep gitlab gitlab-ce-8.17.5-ce.0.el6.x86_64 gitlab 版本号需注意两位就可以
最后保存即可
选择立即构建后左下角显示时间和序列
点击#号