OpenShift 4 Tekton - Tekton实现包含Gogs+SonaQube+Nexus+Report+WebHook的Pipeline

OpenShift 4.x HOL教程汇总
说明:本文已经在OpenShift 4.10 + OpenShift Pipeline 1.7.2 环境中验证

说明

本文是 aolle 在其 github 上的一个 Tekton Pipeline 演示示例,它是《OpenShift 4 之实现一个基于 Gogs+Nexus+Sonarqube 的Jenkins CI/CD Pipeline》的 Tekton 升级版本。示例演示了 Dev和 Stage的 CI/CD 过程。在这个 Tekton Pipeline 中集成了 Gogs、SonaQube、Nexus、Report等DevOps 工具。
在这里插入图片描述
注意:因为原有 Repo 中有少量问题,本文使用 Fork 的仓库 https://github.com/liuxiaoyu-git/tekton-cd-demo

安装配置

安装 OpenShift Pipeline 和客户端

  1. 在 OpenShift 上使用默认配置安装 OpenShift Pipeline Operator。
  2. 在客户机安装 Tekon 环境。
$ curl -L https://github.com/tektoncd/cli/releases/download/v0.25.0/tkn_0.25.0_Linux_x86_64.tar.gz | tar -xzf -
$ sudo mv tkn /usr/local/bin/

安装演示环境和 Pipeline

  1. 下载 tekton-cd-demo,然后运行安装命令。
$ git clone https://github.com/liuxiaoyu-git/tekton-cd-demo && cd tekton-cd-demo 
$ ./demo.sh install --project-prefix <PREFIX>
 
。。。。
############################################################################
############################################################################
  Demo is installed! Give it a few minutes to finish deployments and then:

  1) Go to spring-petclinic Git repository in Gogs:
     http://gogs-demo-cicd.apps.cluster-g2gxv.g2gxv.sandbox1416.opentlc.com/gogs/spring-petclinic.git
  2) Log into Gogs with username/password: gogs/gogs
  3) Edit a file in the repository and commit to trigger the pipeline
  4) Check the pipeline run logs in Dev Console or Tekton CLI:
    $ tkn pipeline logs petclinic-deploy-dev -f -n demo-cicd

  You can find further details at:

  Gogs Git Server: http://gogs-demo-cicd.apps.cluster-g2gxv.g2gxv.sandbox1416.opentlc.com/explore/repos
  Reports Server: http://reports-repo-demo-cicd.apps.cluster-g2gxv.g2gxv.sandbox1416.opentlc.com
  SonarQube: https://sonarqube-demo-cicd.apps.cluster-g2gxv.g2gxv.sandbox1416.opentlc.com
  Sonatype Nexus: http://nexus-demo-cicd.apps.cluster-g2gxv.g2gxv.sandbox1416.opentlc.com
############################################################################
############################################################################
  1. 在安装完后,在 OpenShift 控制台的 Developer 视图中查看 PREFIX-cicd 项目的 Topology 包括以下部署对象。
    在这里插入图片描述
    说明:如果安装的时候曾出现 gogs 部署找不到 gogs-config 的情况,可以无需删除资源再次执行一次安装。

  2. 根据以上提示用对应用户访问 Gogs、Nexue、SonaQube、Reports 地址,登录方式如下:
    Gogs git server (username/password: gogs/gogs)
    Sonatype Nexus (username/password: admin/admin123)
    SonarQube (username/password: admin/admin)
    其中 Gogs 上有 3 个仓库,其中 spring-petclinic 是应用的源码,spring-petclinic-config 是应用部署的配置文件。
    在这里插入图片描述
    并且 spring-petclinic 仓库已经自动配置好了 Webhook。
    在这里插入图片描述

运行 Pipeline

  1. 运行pipeline,然后在OpenShift控制台的PREFIX-cicd项目中查看Pipeline运行情况。
$ ./demo.sh start
  1. 查看管道运行
    在这里插入图片描述
    查看管道运行的日志
    在这里插入图片描述
  2. 在Pipeline完成后查看Gogs、Nexue、SonaQube、Reports结果。
    Report的性能报告:
    在这里插入图片描述
    Nexus 中的 maven-public:
    在这里插入图片描述
    Sonaqube 的测试结果:
    在这里插入图片描述
  3. 在 PREFIX-dev 项目中访问 petclinic 应用。
    在这里插入图片描述
  4. 在 Gogs 中修改下图路径中的 messages.properties 文件内容,将 welcome 设为 “Welcome Pet Clinic”,然后点击 “Commit Changes”。
    在这里插入图片描述
  5. 确认 OpenShift 启动新的 Pipeline Run。在运行结束后查看应用已经被更新。
  6. 在 PREFIX-cicd 项目中手动 Strat 名为 petclinic-deploy-stage 的 Pipeline,然后在弹出窗口提供以下配置参数。
    在这里插入图片描述
  7. 查看“管道运行”的执行情况。
    在这里插入图片描述
  8. 在 PREFIX-stage 项目中查看部署的应用。
    在这里插入图片描述

参考

https://github.com/aolle/tekton-cd-demo


版权声明:本文为weixin_43902588原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。