Skip to content

2、实战:Pig微服务项目下载代码流水线配置-2024.6.22

实战:Pig微服务项目下载代码流水线配置-2024.6.22

image-20240622071227848

image-20240622071648635

目录

[toc]

环境

bash
Jenkins2.415-jdk11GitLabgitlab-ce:16.2.2-ce.0Terraform1.1.7Kind0.14.0Kubernetes1.24.0(具备nfs存储)Docker-CE1.19+(Docker version23.0.3,build3e7cbfd)ArgoCD2.6.7centos77.6.1810

前提

基础环境已具备。(kind搭建的k8s集群、jenkins、gitlab环境已具备)

具体搭建见如下文档:

image-20240622152644451

《00-devops8基础环境配置(重要)》 https:gitinit--initial-branch=maingitremoteaddoriginhttp:gitadd.gitcommit-m"Initial commit"gitpush--set-upstreamoriginmain

image-20240619230653321

2.gitlab上创建前端项目:devops8-microservices-web

前端用npm打包,测试过了,没问题

这个项目没提供helm chart,我们得自己写。

但是他有docker-compose,我们基于它转换就好。

  • 创建项目,并将本地代码上传gitlab仓库

image-20240619230830805

bash
cdexisting_foldergitinit--initial-branch=maingitremoteaddoriginhttp:gitadd.gitcommit-m"Initial commit"gitpush--set-upstreamoriginmain
  • 将老师提供的代码解压
bash
cdexisting_foldergitinit--initial-branch=maingitremoteaddoriginhttp:gitadd.gitcommit-m"Initial commit"gitpush--set-upstreamoriginmain

image-20240619230958286

2、jenkins上创建后端和前端pipeline

1.jenkins上创建devops8-microservices-backend_CI流水线

image-20240619231114414

这一期的变化有点大:按微服务方式来做

添加2个选项参数:

bash
srcUrlhttp:branchNamemain

image-20240619231338204

image-20240619231358886

  • 配置从gitlab 共享库地址
bash
http:defMyTest =neworg.devops.MyTest()currentBuild.displayName ="${env.branchName}"currentBuild.description ="xxx"pipeline{agent {label "build"}options {skipDefaultCheckout true}stages{stage("GetCode"){steps{script {checkout scmGit(branches:[[name:"${env.branchName}"]],extensions:[],userRemoteConfigs:[[credentialsId:'00452180-aa3f-4a39-9bef-b04d8136454b',url:"${env.srcUrl}"]])	}sh "ls -l"}}}}

然后提交。

2.jenkins上创建devops8-microservices-web_CI流水线

按以上方法配置前端项目。

  • 以后端项目为基础克隆到一个新项目:devops8-microservices-web_CI

image-20240622062018787

  • 修改选项参数srcUrl里仓库地址为前端项目
bash
srcUrlhttp:branchNamemain

image-20240622062214524

  • 查看gitlab 共享库地址
bash
http:defMyTest =neworg.devops.MyTest()currentBuild.displayName ="${env.branchName}"currentBuild.description ="xxx"pipeline{agent {label "build"}options {skipDefaultCheckout true}stages{stage("GetCode"){steps{script {checkout scmGit(branches:[[name:"${env.branchName}"]],extensions:[],userRemoteConfigs:[[credentialsId:'00452180-aa3f-4a39-9bef-b04d8136454b',url:"${env.srcUrl}"]])	}sh "ls -l"}}}}

然后提交。

3、测试下载代码流水线

1.测试后端项目下载代码流水线

  • 运行流水线测试效果(运行成功)

image-20240622061426795

image-20240622061409378

奇怪,前端项目这里下载的文件为啥这么少呀……

2.测试前端项目下载代码流水线

image-20240622062439582

运行成功:

image-20240622062531330

image-20240622062524088

4、创建一个devops8视图

创建视图:

image-20240622062809267

bash
^devops08-(.*?)devops8

image-20240622062959351

image-20240622063006807

测试结束。

总结

目前只实现了代码下载功能,后续将继续晚上流水线。

  • pipeline

image-20240622063245359

  • 业务代码
bash
http:http:

版权:此文章版权归 One 所有,如有转载,请注明出处!

链接:可点击右上角分享此页面复制文章链接

上次更新时间:

最近更新