当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
- FreeSWITCH视频会议“标准”解决方案
- Introduction to Huawei cloud micro certification examination
- Exclusive interview of guests at | 2020 PostgreSQL Asia Conference: Wang Tao
- Interviewer: how about shardingsphere
- Common syntax corresponding table of mongodb and SQL
- Two dimensional code location and alarm system of Expressway
- 大佬们如何在nginx镜像里面增加模块?
- The isolation level of transaction and its problems
- September 3, 2020: naked writing algorithm: loop matrix traversal.
猜你喜欢
MRAM高速缓存的组成
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
超高频RFID医疗血液管理系统应用
2020-08-14:数据任务的执行引擎用的哪些?
How to add modules to nginx image?
The isolation level of transaction and its problems
20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
2020-09-04: do you understand the function call convention?
甘特图对活动进行分组教程
随机推荐
2020-08-17: how to solve data skew in detail?
STM32F030K6T6兼容替换灵动MM32F031K6T6
图像处理工具包ImagXpress使用教程,如何查看事件
Qt音视频开发46-视频传输UDP版
What are the highlights of Huawei mate 40 series with HMS?
心理咨询app开发所具备的优点与功能
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大
How to deploy Gantt chart quickly and correctly
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
“非洲用户的付费意愿并不低”——专访四达时代研发总监张亮
Common syntax corresponding table of mongodb and SQL
Novice guidance and event management system in game development
To solve the problem that the data interface is not updated after WPF binding set
插件Bilibili新版0.5.5
ImageMagick - 添加水印
移动端像素适配方案
Win7 AppCrash (solution)
The memorandum model of behavior model
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud