jenkins

Posted sunyujun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jenkins相关的知识,希望对你有一定的参考价值。

jenkins介绍

技术分享图片

 技术分享图片

 jenkins安装

技术分享图片

1.安装openjdk

[[email protected] ~]# yum install -y java-1.8.0-openjdk

2.安装Jenkins yum源

[[email protected] ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo

3.安装Jenkins  key

[[email protected] ~]# rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
[[email protected] ~]# 

4.yum安装

[[email protected] ~]# yum install -y jenkins

5.启动Jenkins

[[email protected] ~]# systemctl start jenkins
[[email protected] ~]# ps aux|grep jenkins
jenkins    3492 64.2  6.2 2252192 62356 ?       Ssl  15:38   0:21 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/libjenkins -jar
/usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20 root 3513 1.0 0.0 112664 936 pts/0 R+ 15:39 0:00 grep --color=auto jenkins [[email protected] ~]#

6.我们可以在Jenkins日志中查看jenkins密码,或是在initialAdminPassword文件中查看

[[email protected] yum.repos.d]# less /var/log/jenkins/jenkins.log 
[[email protected] yum.repos.d]# 
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

8a72142953e9417f81970ffcb9366194

This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
[[email protected] yum.repos.d]# cat /var/lib/jenkins/secrets/initialAdminPassword 
8a72142953e9417f81970ffcb9366194
[[email protected] yum.repos.d]# 

了解jenkins

1.浏览器访问192.168.133.66:8080进入jenkins页面,选择安装推介插件。

2.创建第一个管理员用户,下一步安装成功

技术分享图片

3.jenkins配置文件目录

[[email protected] yum.repos.d]# vim /etc/sysconfig/jenkins 
[[email protected] yum.repos.d]# 

4.程序主目录(如果想备份,直接拷贝这个目录就可以了)

[[email protected] yum.repos.d]# cd /var/lib/jenkins/
[[email protected] jenkins]# ls
config.xml                                      nodeMonitors.xml
hudson.model.UpdateCenter.xml                   nodes  (多节点的时候用到的目录)
hudson.plugins.git.GitTool.xml                  plugins (插件目录)
identity.key.enc                                secret.key
jenkins.CLI.xml                                 secret.key.not-so-secret
jenkins.install.InstallUtil.installingPlugins   secrets
jenkins.install.InstallUtil.lastExecVersion     updates
jenkins.install.UpgradeWizard.state             userContent
jenkins.model.JenkinsLocationConfiguration.xml  users
jobs     (我们创建的任务所在的目录)                                       workflow-libs
logs     (日志相关目录)
[[email protected] jenkins]#

发布php代码(上)  

技术分享图片

1.在创建任务之前我们需要安装必须的两个插件系统管理-》管理插件-》已安装插件列表中看是否安装了Git plugin和publish over ssh,发现没有publish over ssh我们从可选插件中安装,选中直接安装,安装完成之后,linux服务器直接重启Jenkins。

[[email protected] jenkins]# systemctl restart jenkins
[[email protected] jenkins]# 

2.在配置publish over ssh之前需要生成一对秘钥,如果服务器上有默认的秘钥对可以不生成直接用

[[email protected] jenkins]# 
[[email protected] jenkins]# cd /root/.ssh/
[[email protected] .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[[email protected] .ssh]# 

3.将私用填到key中  

[[email protected] .ssh]# cat id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEA2M8M7nJ9SZEklwQzQGfSjQG0RS1Bp9u8Xif9x+25FwvBaXTX
3rErqBwx4N/kcS5zmu4eTNny2/04bz86ZfAQOT2Hc2Pmnao2M5Ggrm1P2I7eRr2V
dJUyTfl7MX/F+MF0LWSkHYCin/no6Oju3yJcD5sqZPZ3ekY4CqA3uObOI1h7dB7b
WAhvtiBy0/oDCnDT75BD70apzpWTBVuHun7Mmgc3z/r3pyzFPspLr5h/YN0o4dnV
BdcHd3M8WHJ8QhVm8capLh/FQFGRSfA6QYdxugsvwOP+TM6aymP8d46THym5K15J
4HJ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zQUnwhjfbVZA5bCZLFZXAXfHUJ
3d4BAoGABifvGGtRUiOhdOeWXbb5kdwD0dbn+33b5XDMwaHrvU8CAxV3qcC2f4yp
yGOH84LinfasLO0I6aNQ/XCCZcQ3yy1I/iiwVFmBvJEtVYO5Jfsb5TGm7coMwJe6
9YKUJ/NOBqEkaXzssVoUZhc+Kf37GQvH5VwlfHEaN5xZZ2TpOko=
-----END RSA PRIVATE KEY-----
[[email protected] .ssh]# 

技术分享图片

4.将公钥配置到远程机器上(centos-01)

[[email protected] .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYzwzucn1JkSSXBDNAZ9KNAbRFLUGn27xeJ/3H7bkXC8FpdNfesSuoHDHg3+RxLnOa7h5M2fLb/ThvPzpl8BA5PYdzY+adqjYzkaCubU/Yjt5GvZV0lTJN+Xsxf8X4wXQtZKQdgKKf+ejo6O7
fIlwPmypk9nd6RjgKoDe45s4jWHt0HttYCG+2IHLT+gMKcNPvkEPvRqnOlZMFW4e6fsyaBzfP+venLMU+ykuvmH9g3Sjh2dUF1wd3czxYcnxCFWbxxqkuH8VAUZFJ8DpBh3G6Cy/A4/5MzprKY/x3jpMfKbkrXkngcnfuCg9oEhTX9cNdbb3UUS
rc+lQNbj3aOMmL [email protected] [[email protected] .ssh]#
[[email protected] ~]# vim .ssh/authorized_keys 
[[email protected] ~]# cat .ssh/authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD810lCxBhCtMzrmSx302M6PUMKRxNK0TBrFQzwbsL8KAcgJXvH0ysc5OIw8lEFpIQirmZODVHg85I/2u3Xgz9yEf5ucF33R0xjJpcD0sq9LvMj0A2lO2RppsjgNyA4wcYcxfOg9HcYI97622l
ssO5012qWbr6k9Bv3QOD0r+F6mdoFXvXFIF2YL//60kPcPXzyPgW6ErDkA1Pum9DQOiys6iN/tH4iCa7ynRzCkLlVxt21V8mrewAldn/JOMuJVEcUtKrmtH+6wny6sJHqEStlF46xZyIH1/SeDyd8oCDwC+PU2HLTc3hishe/ny8ofm9QcC+zgb
BSPnm+I1+/vwfZ [email protected] ##centos02 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYzwzucn1JkSSXBDNAZ9KNAbRFLUGn27xeJ/3H7bkXC8FpdNfesSuoHDHg3+RxLnOa7h5M2fLb/ThvPzpl8BA5PYdzY+adqjYzkaCubU/Yjt5GvZV0lTJN+Xsxf8X4wXQtZKQdgKKf+ejo6O7
fIlwPmypk9nd6RjgKoDe45s4jWHt0HttYCG+2IHLT+gMKcNPvkEPvRqnOlZMFW4e6fsyaBzfP+venLMU+ykuvmH9g3Sjh2dUF1wd3czxYcnxCFWbxxqkuH8VAUZFJ8DpBh3G6Cy/A4/5MzprKY/x3jpMfKbkrXkngcnfuCg9oEhTX9cNdbb3UUS
rc+lQNbj3aOMmL [email protected] [[email protected] ~]#

5.测试ssh是否能登录

[[email protected] .ssh]# ssh centos-02
The authenticity of host ‘centos-02 (192.168.133.88)‘ can‘t be established.
ECDSA key fingerprint is bf:dc:4b:e3:1c:99:f4:12:6f:d0:a8:e0:13:8a:d0:dd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘centos-02‘ (ECDSA) to the list of known hosts.
Last login: Mon Jun 25 18:53:00 2018 from 192.168.133.1
[[email protected] ~]# 

5.配置ssh server

技术分享图片

6.点击test测试成功

技术分享图片

7.保存即可

发布php代码(下)

  

 

 

  

  

 








以上是关于jenkins的主要内容,如果未能解决你的问题,请参考以下文章

jenkins持续集成工作原理

14-Jenkins-Pipeline实现自动部署

jenkins-系统管理-节点管理进去报错

Jenkins发送html格式的邮件,收到的显示乱码,而且木有格式

如何在运行Jenkins CI管道时屏蔽作为用户输入传递的密码?

Jenkins发送html格式的邮件,收到的显示乱码,而且木有格式