当前位置:网站首页>Pipeline pipeline project is built by declarative and jenkinsfile under Jenkins
Pipeline pipeline project is built by declarative and jenkinsfile under Jenkins
2022-07-24 00:10:00 【cristianoxm】
One 、Pipelin brief introduction
- Concept
Pipeline, Simply speaking , Namely bash One set runs on Jenkins Workflow framework on , It will run independently on a single or multiple nodes Connect your tasks , To realize the complex process arrangement and visualization work that single task is difficult to complete .
- Use Pipeline There are the following benefits ( From translation from official documents ):
- Code :Pipeline In the form of code , Usually checked into source code control , Enables the team to edit , Review and iterate its delivery process .
- persistent :
Whether it's a planned or unplanned server restart ,Pipeline It's all recoverable.- Can stop :Pipeline
Can receive interactive input , To determine whether to proceed with Pipeline.- multi-function :
Pipeline Support complex continuous delivery requirements in the real world . It supports fork/join、 Loop execution , The ability to perform tasks in parallel.- Scalable :Pipeline plug-in unit
Support its DSL Custom extension for, And multiple options for integration with other plug-ins .
- How to create Jenkins Pipeline Well
- Pipeline The script was created by Groovy The realization of language , But we don't have to study alone Groovy
- Pipeline Two kinds of grammar are supported :Declarative( declarative ) and
Scripted Pipeline( Scripted ) grammar- Pipeline There are also two ways to create : Can be directly in Jenkins Of Web UI Input script in the interface ; You can also create a individual Jenkinsfile The script file is put into the source library of the project
( Generally, we recommend Jenkins Directly from source control (SCM) Directly loaded in Jenkinsfile Pipeline This method ).
Two 、 stay jenkins Install in Pipeline plug-in unit

After installing the plug-in , There's more time to create projects “ Assembly line ” type

3、 ... and 、 Create a pipeline project
- Declarative declarative
- Create project :


The automatically generated script is as follows :

- stages: Representing the whole assembly line
All execution phases. Usually stages Only 1 individual , It contains more than one stage- stage:
Represents a stage in the pipeline , May appear n individual. It is generally divided into pull code , Compiling and constructing , Deployment and so on .- steps:
Represents the logic that needs to be executed in a phase.steps Inside is shell Script ,git Pull the code ,ssh Any content such as remote Publishing .
Pull the code

Deploy to tomcat

The overall script is as follows :
pipeline {
agent any
stages {
stage ('pull code') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: '2121e63d-3284-4703-9cf7-4ccf9bc536c2', url: '[email protected]:xxxxx/jenkins_war.git']]])
}
}
stage ('bulid project') {
steps {
sh 'mvn clean package'
}
}
stage ('deploy to tomcat') {
steps {
deploy adapters: [tomcat9(credentialsId: '68a5c257-6180-4d44-be87-9dda0daf2ba5', path: '', url: 'http://10.10.10.14:8080/')], contextPath: null, war: 'target/*.war'
}
}
}
}
- The console output is as follows


- Pipeline Script from SCM(Jenkinsfile The way , It can be directly to Jenkinsfile Version control )
Recommended
Just now we were all directly in Jenkins Of UI Interface writing Pipeline Code , This is not convenient for script maintenance , Make a proposal to Pipeline Script placement
In the project ( Version control together )
- Created in the project root directory Jenkinsfile file , Copy the contents into the file ,pull To remote warehouse
pipeline {
agent any
stages {
stage ('pull code') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: '2121e63d-3284-4703-9cf7-4ccf9bc536c2', url: '[email protected]:xxxx/jenkins_war.git']]])
}
}
stage ('bulid project') {
steps {
sh 'mvn clean package'
}
}
stage ('deploy to tomcat') {
steps {
deploy adapters: [tomcat9(credentialsId: '68a5c257-6180-4d44-be87-9dda0daf2ba5', path: '', url: 'http://10.10.10.14:8080/')], contextPath: null, war: 'target/*.war'
}
}
}
}
- New pipeline project

- Building again can also succeed
边栏推荐
- The QT creation window is blocked and cannot be displayed in time
- Operating system not found solution after importing ISO into virtual machine
- Ansible command auto completion
- PyTorch 中遇到的问题
- 474-82(8、221、300)
- logback
- 【语音合成】TensorFlowTTS 中文文本转语音
- DGS file upload
- 【OpenCV】- cv.threshold()函数的参数type是数字时,代表的含义
- 腾讯将关闭“幻核”,数字藏品领域发展是否面临阻力?
猜你喜欢

数据驱动之Excel读写

Linked list - 206. Reverse linked list (this question is very important)

链表——206. 反转链表(这题很重要)

Esp8266 - at command + network transparent transmission

iNFTnews | 呵护“雪山精灵”,42VERSE“数字生态保护”公益项目即将盛启

Automatic escape processing in JMeter

After openfeign sets circuitbreaker=true, feign's readtimeout expires

Qt创建背景遮罩,弹出子窗口,父窗口背景变黑变暗
![[attack and defense world web] difficulty five-star 15 point advanced question: bug](/img/24/4a7f074aac9a08130cf215f0c39b57.png)
[attack and defense world web] difficulty five-star 15 point advanced question: bug

深度学习之 9 前馈神经网络 基本概念
随机推荐
How to open an account and buy financial products with 6% income?
Space shooting lesson 08: improved collision
Sum of submatrix
Linked list - 206. Reverse linked list (this question is very important)
太空射击 第07课: 添加图形
世界最小的物质排名,灵子,弦子,夸克
JMeter中的自动转义处理
Scheme for importing XMIND use cases into tapd (with code)
什么是 Restful 动词
2022年7月23日——mapper文件说明
Nacos
【细节】radio 标签 ,更换 默认选中的背景色
String function 1 of C language
Qt创建窗口被阻塞不能及时显示的问题
自己喜欢投资
链表——206. 反转链表(这题很重要)
Redis cluster construction (cluster cluster mode, fragment cluster)
Chapter 4: implementation use cases
[translation] Introduction to go RPC: Hello World
【微服务架构】分布式事务
