|NO.Z.00038|——————————|CloudNative|——|CI/CD&Jenkins_pipeline操作.V12|——|Jenkins_pipeline插件|

一、Jenkins pipeline插件安装
### --- Jenkins pipeline概述
### --- 安装jenkins pipeline插件

~~~     ——>在对 jenkins 进行初始化安装时,默认已经安装了 jenkins 的相关插件,如下图所示:
二、Jenkins pipeline配置流水线
### --- Jenkins pipeline配置流水线

~~~     # 新建任务
~~~     ——>编写 pipeline 脚本
~~~     ——>可以借助流水线语法去做。
~~~     # ——>test 流水线脚本:

node {
   def mvnHome
   stage('git checkout') { #for display purposes
        checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'git@10.10.10.13:/home/git/repos/app.git']]])
   }
   stage('maven Build') {
        echo "maven build........."
   }
   stage('deploy') {
        echo "deploy..........."
   }
   stage('test') {
        echo "test..........."
   }
}
三、构建测试
### --- 构建测试
~~~     ——>可以去服务器上验证一下(git checkout)刚才拉取下来的代码:

[root@jenkins ~]# ll /var/lib/jenkins/workspace/pipeline-test/
total 0
-rw-r--r-- 1 root root 0 Mar 30 16:59 index1.html
-rw-r--r-- 1 root root 0 Mar 30 16:59 index.html
~~~     # ——>补充:
~~~     ——>可以从代码版本管理仓库中读取 pipeline 脚本(相当于将 pipeline 脚本放在仓库中)可以选择git。
~~~     ——>首先需要将 pipeline 脚本提交到我们新建的 git仓库中(步骤再此忽略。)
四、jenkins 项目中需要进行如下配置:
### --- jenkins 项目中需要进行如下配置:

~~~     ——>其中脚本路径的配置,一定要和版本仓库中的路径相一致。
~~~     ——>之后如果要更改步骤,不需要再更改 jenkins 的步骤,直接更改文件即可。
~~~     # ——>补充:
~~~     ——>此外之前的测试一直是在 master上构建的,我们还可以通过在 jenkinsfile 中指定节点在相应节点去构建具体在 jenkinsfile 的 node 后进行指定:
~~~     ——>如下图所示:

[root@jenkins ~]# vim /root/jenkinsfile/item-a/jenkinsfile
node ("slave01-10.10.10.11"){
   def mvnHome
   stage('git checkout') { 
        checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'git@10.10.10.13:/home/git/repos/app.git']]])
   }
   stage('maven Build') {
        echo "maven build........."
   }
   stage('deploy') {
        echo "deploy..........."
   }
   stage('test') {
        echo "test..........."
   }
}
~~~     ——>格式为:node ("节点名称")
~~~     ——>**具体配置详解请参考** https://jenkins.io/doc/book/pipeline/

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(25)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示