当前位置:网站首页>Introduction to Jenkins (2) declarative pipeline
Introduction to Jenkins (2) declarative pipeline
2020-11-06 22:33:00 【Super_ Charles】
1. Jenkins Pipeline Basic concepts
Pipeline is a user-defined CD Pipeline model . The pipeline code defines the entire build process , It usually involves building , The phase of testing and delivering an application . Jenkins Pipeline
( Or for short "Pipeline") It's a set of plug-ins , Integrate the implementation and implementation of continuous delivery into Jenkins in . Continuous delivery Pipeline
Automation expresses such a process : Continuous delivery of software based on version control management . Jenkins Pipeline The definition of is usually written into a Jenkinsfile
In the text file , This file can be placed in the project's source code control library .
2.Jenkinsfile Basic grammar
pipeline { // Specific grammar ,pipeline The block defines all the work done in the pipeline
agent any // agent Assign an actuator to the entire pipeline ( On the node ) And the work area
stages { // All processes ( state ) The outer block of , There is only one
stage('Build') { // Every stage It's a process , Definition name
steps { // Step block , Internal contains specific operations
sh 'make' // sh operation , The words between the quotation marks will look like shell Direct execution
}
}
stage('Test'){
steps {
sh 'make check'
junit 'reports/**/*.xml' //junit Use matching definitions to test xml Unit test
}
}
stage('Deploy') {
steps {
sh 'make publish'
}
}
}
}
3. establish Hello World Assembly line
- Sign in
Jenkins
, A new task (New Item), choiceAssembly line
, Enter the project nameHello Pipeline
, determine . - Fill in the description , Check
Parametric build process (This project is parameterized)
. - Add parameter , choice
Character parameters (String parameter)
, And set the string parameter ( name , The default value is , describe ), So we are Jenkinsfile You can get this value in . - Slide down to
Assembly line
, Define choicePipeline script
, The script inputs the following , Then save .
pipeline {
agent any
environment { // environment variable
GREETING="Hello"
}
stages{
stage(' Say hello ') {
steps{
sh 'echo "$GREETING $TITLE"'
}
}
}
post { // After the build is completed, the post operation
aborted { // If the build breaks , execute
echo ' Build aborted !'
}
success { // Build successfully executed
echo ' Building a successful !'
}
failure { // Build failed execution
echo ' Build failed !'
}
}
}
-
Click on
Build with Parameters( Parametric construction )
, thenBegin to build
. -
Build the output interface :
-
Put the mouse on the green box under the greeting , The dot appears
logs
, You can see that the expected value is output . -
Find the... In the lower left corner
Build History( Building history )
The build version number of , If it is at present#1
, Click in , choiceConsole Output
View the detailed execution log .
# success Console Output
Started by user charles
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /home/jenkins/root/workspace/Hello Pipeline
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { ( Say hello )
[Pipeline] sh
+ echo 'Hello Jenkins Pipeline'
Hello Jenkins Pipeline
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Building a successful !
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
版权声明
本文为[Super_ Charles]所创,转载请带上原文链接,感谢
边栏推荐
- Hdu3974 assign the task segment tree DFS order
- The method of local search port number occupation in Windows system
- Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
- 打工人好物——磨炼钢铁意志就要这样高效的电脑
- How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
- Bluetooth broadcast chip for Shanghai giant micro
- Interviewer: how about shardingsphere
- [forward] how to view UserData in Lua
- Application of UHF RFID medical blood management system
- Experiment one
猜你喜欢
How to optimize the decoding performance of dynamsoft barcode reader
The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
Dynamsoft barcode reader v7.5!
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
Plug in bilibilibili new version 0.5.5
Big data processing black Technology: revealing the parallel computing technology of Pb level data warehouse gaussdb (DWS)
非易失性MRAM存储器应用于各级高速缓存
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
How to start the hidden preferences in coda 2 on the terminal?
随机推荐
Message queue - Analysis
JVM class loading mechanism
Novice guidance and event management system in game development
C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
Nonvolatile MRAM memory used in all levels of cache
Benefits and functions of auto maintenance app development
Points to be considered when deleting mapping field of index in ES
How to use Gantt chart layers and filters
[doodling the footprints of Internet of things] Introduction to Internet of things
细数软件工程----各阶段必不可少的那些图
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
Jenkins入门(二)声明式流水线Jenkins Pipeline
Markdown tricks
轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
汽车维修app开发的好处与功能
QT audio and video development 46 video transmission UDP version
ImageMagick - 添加水印
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
Common syntax corresponding table of mongodb and SQL