devops
devops基础01--gitlab - omgasw - 博客园 (cnblogs.com)
devops基础02--jenkins - omgasw - 博客园 (cnblogs.com)
devops基础03--sonarqube - omgasw - 博客园 (cnblogs.com)
devops基础04--maven - omgasw - 博客园 (cnblogs.com)
devops基础06--maven pom.xml - omgasw - 博客园 (cnblogs.com)
devops基础05--nexus - omgasw - 博客园 (cnblogs.com)
$
$
$
jenkins
Jenkins是一款开源 CI&CD 软件,用于自动化各种任务,包括构建、测试和部署软件
1.jenkins install
1.通过rpm包安装
从清华大学源下载安装包
Index of /jenkins/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
# 先安装openjdk yum -y install java-11-openjdk-devel # 安装jenkins rpm -ivh jenkins-2.289.2-1.1.noarch.rpm # 修改启动用户 [root@jenkins01 ~]# egrep -v '^$|#' /etc/sysconfig/jenkins NKINS_HOME="/var/lib/jenkins" JENKINS_JAVA_CMD="" JENKINS_USER="jenkins" ##可以修改成root,生产环境不建议修改 JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true" JENKINS_PORT="8080" JENKINS_LISTEN_ADDRESS="" JENKINS_HTTPS_PORT="" JENKINS_HTTPS_KEYSTORE="" JENKINS_HTTPS_KEYSTORE_PASSWORD="" JENKINS_HTTPS_LISTEN_ADDRESS="" JENKINS_HTTP2_PORT="" JENKINS_HTTP2_LISTEN_ADDRESS="" JENKINS_DEBUG_LEVEL="5" JENKINS_ENABLE_ACCESS_LOG="no" JENKINS_HANDLER_MAX="100" JENKINS_HANDLER_IDLE="20" JENKINS_EXTRA_LIB_FOLDER="" JENKINS_ARGS="" # 启动 sudo systemctl daemon-reload sudo systemctl restart jenkins
2.通过web页面继续安装
##
2.插件管理
1.手动导入
插件路径
[root@jenkins01 ~]# ls /var/lib/jenkins/plugins/ ace-editor bouncycastle-api command-launcher email-ext github.jpi jdk-tool lockable-resources pam-auth pipeline-model-api pipeline-stage-view scm-api structs workflow-basic-steps workflow-scm-step ace-editor.jpi bouncycastle-api.jpi command-launcher.jpi email-ext.jpi git.jpi jdk-tool.jpi lockable-resources.jpi pam-auth.jpi pipeline-model-api.jpi pipeline-stage-view.jpi scm-api.jpi structs.jpi workflow-basic-steps.jpi workflow-scm-step.jpi ant branch-api credentials font-awesome-api git-server jjwt-api mailer pipeline-build-step pipeline-model-definition plain-credentials script-security timestamper workflow-cps workflow-step-api antisamy-markup-formatter branch-api.jpi credentials-binding font-awesome-api.jpi git-server.jpi jjwt-api.jpi mailer.jpi pipeline-build-step.jpi pipeline-model-definition.jpi plain-credentials.jpi script-security.jpi timestamper.jpi workflow-cps-global-lib workflow-step-api.jpi antisamy-markup-formatter.jpi build-timeout credentials-binding.jpi git gradle jquery3-api matrix-auth pipeline-github-lib pipeline-model-extensions plugin-util-api snakeyaml-api token-macro workflow-cps-global-lib.jpi workflow-support ant.jpi build-timeout.jpi credentials.jpi git-client gradle.jpi jquery3-api.jpi matrix-auth.jpi pipeline-github-lib.jpi pipeline-model-extensions.jpi plugin-util-api.jpi snakeyaml-api.jpi token-macro.jpi workflow-cps.jpi workflow-support.jpi apache-httpcomponents-client-4-api caffeine-api display-url-api git-client.jpi handlebars jsch matrix-project pipeline-graph-analysis pipeline-rest-api popper2-api ssh-credentials trilead-api workflow-durable-task-step ws-cleanup apache-httpcomponents-client-4-api.jpi caffeine-api.jpi display-url-api.jpi github handlebars.jpi jsch.jpi matrix-project.jpi pipeline-graph-analysis.jpi pipeline-rest-api.jpi popper2-api.jpi ssh-credentials.jpi trilead-api.jpi workflow-durable-task-step.jpi ws-cleanup.jpi bootstrap4-api checks-api durable-task github-api jackson2-api junit momentjs pipeline-input-step pipeline-stage-step popper-api sshd workflow-aggregator workflow-job bootstrap4-api.jpi checks-api.jpi durable-task.jpi github-api.jpi jackson2-api.jpi junit.jpi momentjs.jpi pipeline-input-step.jpi pipeline-stage-step.jpi popper-api.jpi sshd.jpi workflow-aggregator.jpi workflow-job.jpi bootstrap5-api cloudbees-folder echarts-api github-branch-source jaxb ldap okhttp-api pipeline-milestone-step pipeline-stage-tags-metadata resource-disposer ssh-slaves workflow-api workflow-multibranch bootstrap5-api.jpi cloudbees-folder.jpi echarts-api.jpi github-branch-source.jpi jaxb.jpi ldap.jpi okhttp-api.jpi pipeline-milestone-step.jpi pipeline-stage-tags-metadata.jpi resource-disposer.jpi ssh-slaves.jpi workflow-api.jpi workflow-multibranch.jpi
2.更改国内源
##
3.web页面安装
##
3.配置邮箱通知
1.接收邮箱
2.配置发送端
3.测试发送
3.工具配置
##
4.配置分布式agent
添加node:
1.先在node节点安装JDK
yum -y install java-11-openjdk-devel
2.通过web页面配置
此处工作目录要求与master保持一致
master工作目录位置:
[root@jenkins01 ~]# cd /var/lib/jenkins/ [root@jenkins01 jenkins]# ls config.xml jenkins.install.UpgradeWizard.state nodeMonitors.xml secrets hudson.model.UpdateCenter.xml jenkins.model.JenkinsLocationConfiguration.xml nodes updates hudson.plugins.git.GitTool.xml jenkins.telemetry.Correlator.xml plugins userContent identity.key.enc jobs secret.key users jenkins.install.InstallUtil.lastExecVersion logs secret.key.not-so-secret workflow-libs
node节点要手动创建:
[root@jenkins_agent01 ~]# mkdir -p /var/lib/jenkins
3.创建证书
## 节点属性暂时不做配置
## 节点状态
5.对接gitlab配置密钥
1.在jenkins节点创建密钥对
[root@jenkins01 ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. 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: SHA256:sQC5Nnu899Lcmteb0fSNR3RzxrAngHXxvO+2dgFYC9Q root@jenkins01 The key's randomart image is: +---[RSA 2048]----+ | .. .++ +. | | .. .. E * | | .. . + +.X| | + . o . o ==| | . + S ..o| | . o *+| | . . o . .o B| | . o o.o .*o| | . o+o +++| +----[SHA256]-----+ [root@jenkins01 ~]# ls /root/.ssh/ id_rsa id_rsa.pub
2.将公钥填入gitlab
[root@jenkins01 .ssh]# cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkIazpiMQVNZZyTr5+PmUZVEq4UOKrP1/9yoAsC9hagAQWTxZnt//Pr1usom4Re0AyUuCLboQCGSMftPfBblD/icY85EBtH0atAppKvw9xSoUh/fNw1y56KYYNArkecjFr49WCEuJ4LB8ztMeRwT7oZawJHyFlAe8fJLSjBCB4w4OEJBaLblg2qqE1jyJ25FPPhnBVGDu7wbgdaTtXiob5xZK0bOx5BhHFYBSCe7E7QD4YPbU4fLx8cjACBee+arw3HViMicBGmi1uiTTF8w5Y5ko5Gom5xSRPIxGHz1dxmHrUQ1uF3iYSCVhWPGDD+unJkERVB6fVtoU8QtyeqOXf root@jenkins01
3.在jenkins新建自由项目
4.配置私钥
## 代码管理选择git
5.创建证书
6.拉取code
## 立即构建拉取代码
## 查看日志输出
build
## 配置构建
1.基于shell
## 先做免密钥认证
2.基于pipline
流水线是用户定义的一个CD流水线模型 。流水线的代码定义了整个的构建过程, 他通常包括构建, 测试和交付应用程序的阶段