当前位置:网站首页>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
边栏推荐
猜你喜欢

L2TP的LAC自动拨号实验
![最长递增子序列变种[深刻理解最长递增序列]](/img/73/1480ec319a2860fec5667d6f2fb2ba.png)
最长递增子序列变种[深刻理解最长递增序列]

DDD thinking structure learning
C language explanation series -- understanding of functions (2) how to use functions to exchange the values of two integer variables

深度学习之 9 前馈神经网络2:实现前馈神经网络,模型调优

Idea cannot be switched to Chinese

Intel Intel realsense realistic depth camera self calibration operation steps explanation D400 series is applicable

Windows software: how to install mysql5.7 and configure environment variables

JMeter中的自动转义处理

Pushgateway+prometheus+grafana build Flink real-time monitoring
随机推荐
Scheme for importing XMIND use cases into tapd (with code)
The universal esp32c3 configures partition tables based on the Arduino ide framework
Space shooting lesson 07: add graphics
Intel Intel realsense realistic depth camera self calibration operation steps explanation D400 series is applicable
[wechat Payment]
一改测试步骤代码就全写?为什么不试试用 Yaml实现数据驱动?
【译】Go RPC 入门:Hello World
vulnhub wpwn: 1
北大青鸟昌平校区:运维就业现状怎么样?技能要求高吗?
ESP8266————AT指令+网络透传
Code generation of DGS
Sentinel链路方式流控失效解决
Notes on cmake compilation tool
Redis cluster construction (cluster cluster mode, fragment cluster)
Solution to the second game of 2022 Niuke multi school league
在原生终端实现类似 rz、sz 上传下载文件与目录的功能
YOLOv1
YOLOv1
kubernetes error
Deep learning 9 basic concepts of feedforward neural networks
