Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

"Jenkins 2.x practice Guide" Reading Notes-introduction to Jenkins 2.x and pipeline examples

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

[TOC]

1. What is Jenkins 2.x 1.1 pipeline?

At some abstract level, a deployment pipeline is an automated representation of the process from a software version control library to a user. Continuous Delivery-A Systematic Approach to Delivering Reliable Software (hereinafter referred to as Continuous Delivery)

Jenkins already supports pipelines, as defined in Continuous Delivery (deployment pipelines are often referred to as pipelines, and the two terms will be used interchangeably throughout this book), but they are not called pipelines at first, but tasks.

Jenkins 1.x can only "describe" the deployment pipeline manually through the interface. Jenkins 2.x finally supports pipeline as code, which can describe deployment pipelines by "code."

The significance of using "code" instead of UI is that:

Better versioning: Submit pipelines to software version repositories for version control. Better collaboration: Every change to the pipeline is visible to everyone. In addition to this, pipeline can also be code reviewed. Better reusability: Manual operations cannot be reused, but code can be reused.

This book embraces pipeline as code and abandons freestyle projects that rely on manual manipulation. 1.2 What is Jenkinsfile?

Jenkinsfile is a text file, which is the representation of the deployment pipeline concept in Jenkins. Like Dockerfile to Docker. All deployment pipeline logic is written in Jenkinsfile.

1.3 Choice of pipeline syntax

Jenkins pipeline has two syntax types: scripted syntax and declarative syntax.

The scripted syntax uses Groovy, which has a flexible and extensible syntax, but also means more complexity. Furthermore, the learning costs of Groovy are often unnecessary for development teams (who do not use Groovy). So there is declarative syntax, a syntax that provides a simpler, more opinionated syntax.

Pipeline plug-ins only support two formats of syntax since version 2.5; it is recommended to use declarative syntax mainly, script syntax as an auxiliary;1.4 pipeline version control

For maintenance and collaboration purposes, version control of pipelines using a version repository is optimal for production use.

In practice, I also use Git as a version control repository and Jenkins ssh private key as a certificate mentioned in the recommendation book.

2. Build with github repository pipeline

The following is the experimental address:

https://github.com/ygqygq2/jenkins2_learning_install_tools

objective

Use jenkins to pull pipeline from git repository to build maven project, to understand the basic usage of pipeline.

environment

github repository jenkins (integrated kubernetes)

practice

Go to Manage Jenkins→Global Tool Configuration->Maven page Add mvn-3.5.4

Go to Manage Jenkins→Global Tool Configuration→JDK page Add jdk-8u172

Note that oracle account validation is required here.

Add pipeline project

build

Because jenkins-slave is integrated with kubernetes, tools will be installed every time you build it. As you can see in the above figure, the maven installation package needs to be downloaded from the official website, which has a great impact on efficiency.

To optimize, consider integrating maven directly into a jenkins-slave mirror instead of using jenkins tools; you can also use docker-in-docker with maven mirrors.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report