您的位置:首页 > 汽车 > 时评 > 小蝌蚪幸福宝入口导航_7k7k小游戏大全_seo的培训课程_引流推广平台软件

小蝌蚪幸福宝入口导航_7k7k小游戏大全_seo的培训课程_引流推广平台软件

2025/4/12 6:57:40 来源:https://blog.csdn.net/xiaofengkang/article/details/146537114  浏览:    关键词:小蝌蚪幸福宝入口导航_7k7k小游戏大全_seo的培训课程_引流推广平台软件
小蝌蚪幸福宝入口导航_7k7k小游戏大全_seo的培训课程_引流推广平台软件

jenkins新建测试流水线

新建任务
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

node('testak') {stage('第1步:从gitee上下载源代码') {git url: "https://gitee.com/akang007/jenkins-sample"script {build_tag = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()}}stage('第2步:基于dockerfile文件制作镜像') {sh "docker build -t 192.168.40.62/jenkins-demo/jenkins-demo:${build_tag} ."}stage('第3步:把镜像上传到harbor私有仓库') {withCredentials([usernamePassword(credentialsId: 'dockerharbor', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {sh "docker login 172.16.80.140 -u ${dockerHubUser} -p ${dockerHubPassword}"sh "docker push 172.16.80.140/jenkins-demo/jenkins-demo:${build_tag}"}}stage('第4步:把pod部署到开发环境') {sh "sed -i 's/<BUILD_TAG>/${build_tag}/' k8s-dev-harbor.yaml"sh "sed -i 's/<BRANCH_NAME>/${env.BRANCH_NAME}/' k8s-dev-harbor.yaml"
//        sh "bash running-devlopment.sh"sh "kubectl apply -f k8s-dev-harbor.yaml  --validate=false"}	stage('第5步:把pod部署到测试环境') {	def userInput = input(id: 'userInput',message: '确定部署到测试环境吗?输入yes确定',parameters: [[$class: 'ChoiceParameterDefinition',choices: "YES\nNO",name: 'Env']])echo "This is a deploy step to ${userInput}"if (userInput == "YES") {sh "sed -i 's/<BUILD_TAG>/${build_tag}/' k8s-qa-harbor.yaml"sh "sed -i 's/<BRANCH_NAME>/${env.BRANCH_NAME}/' k8s-qa-harbor.yaml"
//            sh "bash running-qa.sh"sh "kubectl apply -f k8s-qa-harbor.yaml --validate=false"sh "sleep 6"sh "kubectl get pods -n qatest"sh "cd /home/jenkins/agent/workspace/jenkins-harbor"sh "/root/Python-3.12.5/python qatest.py"} else {//exit}}stage('第6步:pod部署到生产环境') {	def userInput = input(id: 'userInput',message: '确定部署到生产环境吗?输入yes确定',parameters: [[$class: 'ChoiceParameterDefinition',choices: "YES\nNO",name: 'Env']])echo "This is a deploy step to ${userInput}"if (userInput == "YES") {sh "sed -i 's/<BUILD_TAG>/${build_tag}/' k8s-prod-harbor.yaml"sh "sed -i 's/<BRANCH_NAME>/${env.BRANCH_NAME}/' k8s-prod-harbor.yaml"
//            sh "bash running-production.sh"sh "cat k8s-prod-harbor.yaml"sh "kubectl apply -f k8s-prod-harbor.yaml --record --validate=false"sh "cd /home/jenkins/agent/workspace/jenkins-harbor"sh "/root/Python-3.12.5/python smtp.py"}}
}

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

Skip to content
[Jenkins]Jenkins
查找 (⌘+K)
1
2
admin注销
Dashboard
jenkins-harbor
#11
状态
变更历史
Console Output
View as plain text
编辑构建信息
删除构建 ‘#11’
Timings
Git Build Data
回放
流水线步骤
Workspaces
上一次构建
Console Output
Started by user admin
[Pipeline] Start of Pipeline
[Pipeline] node
Agent test-p2tjd is provisioned from template test
---
apiVersion: "v1"
kind: "Pod"
metadata:annotations:kubernetes.jenkins.io/last-refresh: "1742977713779"labels:jenkins: "slave"jenkins/label-digest: "0d1a27dd84b68b7896a5df6f824a36e1721850f6"jenkins/label: "testak"kubernetes.jenkins.io/controller: "ttp___jenkins-service_jenkins-k8s_svc_cluster_local_8080x"name: "test-p2tjd"namespace: "jenkins-k8s"
spec:containers:- env:- name: "JENKINS_SECRET"value: "********"- name: "JENKINS_AGENT_NAME"value: "test-p2tjd"- name: "REMOTING_OPTS"value: "-noReconnectAfter 1d"- name: "JENKINS_NAME"value: "test-p2tjd"- name: "JENKINS_AGENT_WORKDIR"value: "/home/jenkins/agent"- name: "JENKINS_URL"value: "http://jenkins-service.jenkins-k8s.svc.cluster.local:8080/"image: "172.16.80.140/jenkins/jenkins.agent:v2"imagePullPolicy: "IfNotPresent"name: "jnlp"resources: {}securityContext:privileged: truetty: truevolumeMounts:- mountPath: "/home/jenkins/.kube"name: "volume-1"readOnly: false- mountPath: "/etc/docker/daemon.json"name: "volume-4"readOnly: false- mountPath: "/usr/bin/kubectl"name: "volume-3"readOnly: false- mountPath: "/usr/bin/docker"name: "volume-2"readOnly: false- mountPath: "/run/docker.sock"name: "volume-0"readOnly: false- mountPath: "/home/jenkins/agent"name: "workspace-volume"readOnly: falseworkingDir: "/home/jenkins/agent"hostNetwork: falsenodeSelector:kubernetes.io/os: "linux"restartPolicy: "Never"serviceAccountName: "jenkins-k8s-sa"volumes:- hostPath:path: "/run/docker.sock"name: "volume-0"- hostPath:path: "/usr/bin/docker"name: "volume-2"- hostPath:path: "/root/.kube"name: "volume-1"- emptyDir:medium: ""name: "workspace-volume"- hostPath:path: "/etc/docker/daemon.json"name: "volume-4"- hostPath:path: "/usr/bin/kubectl"name: "volume-3"Running on test-p2tjd in /home/jenkins/agent/workspace/jenkins-harbor
[Pipeline] {
[Pipeline] stage
[Pipeline] { (第1步:从gitee上下载源代码)
[Pipeline] git
The recommended git tool is: NONE
No credentials specified
Cloning the remote Git repository
Cloning repository https://gitee.com/akang007/jenkins-sample> git init /home/jenkins/agent/workspace/jenkins-harbor # timeout=10
Fetching upstream changes from https://gitee.com/akang007/jenkins-sample> git --version # timeout=10> git --version # 'git version 2.39.5'> git fetch --tags --force --progress -- https://gitee.com/akang007/jenkins-sample +refs/heads/*:refs/remotes/origin/* # timeout=10> git config remote.origin.url https://gitee.com/akang007/jenkins-sample # timeout=10> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision df755ee1bbcf162fbfb6cadf8bb008039d6ccbb6 (refs/remotes/origin/master)
Commit message: "update smtp.py."> git rev-parse refs/remotes/origin/master^{commit} # timeout=10> git config core.sparsecheckout # timeout=10> git checkout -f df755ee1bbcf162fbfb6cadf8bb008039d6ccbb6 # timeout=10> git branch -a -v --no-abbrev # timeout=10> git checkout -b master df755ee1bbcf162fbfb6cadf8bb008039d6ccbb6 # timeout=10> git rev-list --no-walk df755ee1bbcf162fbfb6cadf8bb008039d6ccbb6 # timeout=10
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ git rev-parse --short HEAD
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (第2步:基于dockerfile文件制作镜像)
[Pipeline] sh
+ docker build -t 172.16.80.140/jenkins-demo/jenkins-demo:df755ee .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.Install the buildx component to build images with BuildKit:https://docs.docker.com/go/buildx/Sending build context to Docker daemon  245.2kBStep 1/5 : FROM golang:1.10.4-alpine---> bd36346540f3
Step 2/5 : ADD . /go/src/app---> ffc6aa5f3db2
Step 3/5 : WORKDIR /go/src/app---> Running in 9823c707df6a---> Removed intermediate container 9823c707df6a---> 8de16f4e2759
Step 4/5 : RUN  go build -v -o /go/src/app/jenkins-app---> Running in 8383ac606d62
[91mapp
[0m ---> Removed intermediate container 8383ac606d62---> c56dc76e52d1
Step 5/5 : CMD ["./jenkins-app"]---> Running in a9cfa67f329d---> Removed intermediate container a9cfa67f329d---> de8f85fff5b3
Successfully built de8f85fff5b3
Successfully tagged 172.16.80.140/jenkins-demo/jenkins-demo:df755ee
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (第3步:把镜像上传到harbor私有仓库)
[Pipeline] withCredentials
Masking supported pattern matches of $dockerHubPassword
[Pipeline] {
[Pipeline] sh
Warning: A secret was passed to "sh" using Groovy String interpolation, which is insecure.Affected argument(s) used the following variable(s): [dockerHubPassword]See https://jenkins.io/redirect/groovy-string-interpolation for details.
+ docker login 172.16.80.140 -u admin -p ****
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded
[Pipeline] sh
+ docker push 172.16.80.140/jenkins-demo/jenkins-demo:df755ee
The push refers to repository [172.16.80.140/jenkins-demo/jenkins-demo]
4a8fd9bc91b9: Preparing
67781d6fba74: Preparing
ac1c7fa88ed0: Preparing
cc5fec2c1edc: Preparing
93448d8c2605: Preparing
c54f8a17910a: Preparing
df64d3292fd6: Preparing
c54f8a17910a: Waiting
df64d3292fd6: Waiting
93448d8c2605: Layer already exists
c54f8a17910a: Layer already exists
ac1c7fa88ed0: Layer already exists
cc5fec2c1edc: Layer already exists
df64d3292fd6: Layer already exists
67781d6fba74: Pushed
4a8fd9bc91b9: Pushed
df755ee: digest: sha256:6c80d0f4d2c2bb82ebb3286b874c21b1917ef381e348bcc600b05d5e7dbf899a size: 1785
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (第4步:把pod部署到开发环境)
[Pipeline] sh
+ sed -i s/<BUILD_TAG>/df755ee/ k8s-dev-harbor.yaml
[Pipeline] sh
+ sed -i s/<BRANCH_NAME>/null/ k8s-dev-harbor.yaml
[Pipeline] sh
+ kubectl apply -f k8s-dev-harbor.yaml --validate=false
deployment.apps/jenkins-demo created
service/demo created
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (第5步:把pod部署到测试环境)
[Pipeline] input
Input requested
Approved by admin
[Pipeline] echo
This is a deploy step to YES
[Pipeline] sh
+ sed -i s/<BUILD_TAG>/df755ee/ k8s-qa-harbor.yaml
[Pipeline] sh
+ sed -i s/<BRANCH_NAME>/null/ k8s-qa-harbor.yaml
[Pipeline] sh
+ kubectl apply -f k8s-qa-harbor.yaml --validate=false
deployment.apps/jenkins-demo created
service/demo created
[Pipeline] sh
+ sleep 6
[Pipeline] sh
+ kubectl get pods -n qatest
NAME                            READY   STATUS    RESTARTS   AGE
jenkins-demo-56fd75f4db-5nbst   1/1     Running   0          8s
[Pipeline] sh
+ cd /home/jenkins/agent/workspace/jenkins-harbor
[Pipeline] sh
+ /root/Python-3.12.5/python qatest.py
邮件发送成功!
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (第6步:pod部署到生产环境)
[Pipeline] input
Input requested
Approved by admin
[Pipeline] echo
This is a deploy step to YES
[Pipeline] sh
+ sed -i s/<BUILD_TAG>/df755ee/ k8s-prod-harbor.yaml
[Pipeline] sh
+ sed -i s/<BRANCH_NAME>/null/ k8s-prod-harbor.yaml
[Pipeline] sh
+ cat k8s-prod-harbor.yaml
apiVersion: apps/v1
kind: Deployment
metadata:name: jenkins-demonamespace: production
spec:replicas: 1selector:matchLabels:app: jenkins-demotemplate:metadata:labels:app: jenkins-demospec:containers:- image: 172.16.80.140/jenkins-demo/jenkins-demo:df755eeimagePullPolicy: IfNotPresentname: jenkins-demoenv:- name: branchvalue: null
---
apiVersion: v1
kind: Service
metadata:name: jenkins-demonamespace: production
spec:selector:app: jenkins-demotype: NodePortports:- port: 18888targetPort: 18888nodePort: 31890
[Pipeline] sh
+ kubectl apply -f k8s-prod-harbor.yaml --record --validate=false
Flag --record has been deprecated, --record will be removed in the future
deployment.apps/jenkins-demo created
service/jenkins-demo created
[Pipeline] sh
+ cd /home/jenkins/agent/workspace/jenkins-harbor
[Pipeline] sh
+ /root/Python-3.12.5/python smtp.py
邮件发送成功!
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
Jenkins 中文社区
REST API
Jenkins 2.426.3

开发、测试、生产三个环境都部署了pod和svc,均可以通过访问ip+port的方式访问
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
收到邮件
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com