Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Procedure

Updated on 2025-01-17 GMT+08:00

Scenario

There are components A, B, C, and D in this example.

Component D depends on components B and C, and components B and C depend on component A.

The Jenkins pipeline is used to orchestrate and deploy the four components. You can upgrade one or more components without considering the dependency.

Configuring a Jenkins Pipeline

  1. Go to the Jenkins system management page and click New Item.
  2. Enter a task name and select Pipeline.
  3. On the General page, add Extended Choice Parameter.
  4. Configure the components to be orchestrated.

    Table 1 Configuring build parameters

    Parameter

    Description

    Example

    Name

    Parameter name. The component selected during build is stored in the variable name.

    Model_Name

    Description

    Description of the build parameter.

    Select the components to be upgraded.

    Parameter Type

    Basic parameter type.

    Check Boxes

    Number of Visible Items

    Number of components orchestrated by the pipeline.

    4

    Delimiter

    Separator between components. Set it to a comma (,).

    ,

    Value

    Name of the components orchestrated by the pipeline. Use commas (,) to separate multiple component names.

    componentA, componentB, componentC, componentD

  5. Select Pipeline. On the Pipeline page, configure the script. For details, see Pipeline Script.
  6. Click Save.

Pipeline Script

The pipeline script can upgrade one or more of components A, B, C, and D at the same time. Component A is upgraded first, then components B and C are upgraded concurrently, and finally component D is upgraded. Components that are not selected during the build will be skipped and not upgraded.

pipeline {
    agent any
    environment{
        // The components selected during build are separated by commas (,) and stored in the variable Model_Name.
        // Check whether the optional components in the variable Model_Name exist. If yes, assign the component name to the corresponding variable. If no, assign the string "error" to the corresponding variable.
        // Used to determine whether subsequent components need to be built.
        _componentA="${sh(script:' echo $Model_Name| grep -w -o "componentA" || echo "error" ', returnStdout: true).trim()}"
        _componentB="${sh(script:' echo $Model_Name| grep -w -o "componentB" || echo "error" ', returnStdout: true).trim()}"
        _componentC="${sh(script:' echo $Model_Name| grep -w -o "componentC" || echo "error" ', returnStdout: true).trim()}"
        _componentD="${sh(script:' echo $Model_Name| grep -w -o "componentD" || echo "error" ', returnStdout: true).trim()}"
    }

    stages {
        stage('Build componentA') {
           // When the environment variable _componentA equals to componentA, the component is selected during build. In this case, execute this stage. Otherwise, skip this stage.
            when { environment name: '_componentA', value: 'componentA' }
            steps {
               sh ''' echo "start to build componentA" '''
               script{
                  //build (job: 'componentA') indicates that the component A task is executed. This task is created in Jenkins and is used to upgrade component A.
                  def componentBuild=build(job: 'componentA')
                  // Print the task execution result.
                  println componentBuild.getResult()
               }
            }
        }
        stage('Build parallel jobs') {
            // failFast true indicates that other parallel stages will be stopped as long as one stage fails.
            // If failFast true is not added, the failed stage does not affect the execution of other parallel stages until all parallel stages are complete.
            //failFast true // Add as required.

            // parallel indicates that the stages are executed in parallel. If one stage fails to be executed, the stage in "Build parallel jobs" fails and the subsequent stages will not be executed.
            parallel {
                stage('Build componentB') {
                    when { environment name: '_componentB', value: 'componentB' }
                    steps {
                       sh ''' echo "start to build componentB" '''
                       script{
                          def componentBuild=build(job: 'componentB')
                          println componentBuild.getResult()
                        }
                    }
                }
                stage('Build componentC') {
                    when { environment name: '_componentC', value: 'componentC' }
                    steps {
                       sh ''' echo "start to build componentC" '''
                       script{
                          def componentBuild=build(job: 'componentC')
                          println componentBuild.getResult()
                       }
                    }
                }
            }
        }
        stage('Build componentD') {
            when { environment name: '_componentD', value: 'componentD' }
            steps {
               sh ''' echo "start to build componentD" '''
               script{
                  def componentBuild=build(job: 'componentD')
                  println componentBuild.getResult()
               }
            }
        }
    }
}

Script Description

Each component needs to obtain component parameters from the environment in the pipeline to determine whether the component is selected during parameterized build. Run the following script:

_{component_name}="${sh(script:' echo $Model_Name| grep -w -o "{component_name}" || echo "error" ', returnStdout: true).trim()}"
Table 2 Parameters

Parameter

Description

Model_Name

Name in Configuring build parameters.

{component_name}

One of the component name in Configuring build parameters.

A stage needs to be configured for each component for component upgrade tasks. If the tasks are executed in serial mode, the stages are placed in sequence. If the tasks are executed in parallel mode, the stages are placed in parallel in stage('Build parallel jobs').

Stage script:

stage('Build {component_name}') {
    
    when { environment name: '_{component_name}', value: '{component_name}' }
    steps {
       sh ''' echo "start to build {component_name}" '''
       script{
          def componentBuild=build(job: '{component_jenkins_task}')
          // Print the task execution result.
          println componentBuild.getResult()
       }
    }
}
Table 3 Parameters

Parameter

Description

{component_name}

One of the component name in Configuring build parameters.

{component_jenkins_task}

Name of the component upgrade task created in Jenkins.

Upgrading Multiple Components Using a Pipeline

  1. Select a pipeline and click Build with Parameters.
  2. Select the components to be upgraded. You can select one or more components at the same time. In this example, all components are upgraded at the same time. Click Start Build.
  3. You can view the pipeline task execution result in the build history.
  4. The pipeline log is as follows, indicating that component A is upgraded first, then component B and component C are upgraded concurrently, and finally component D is upgraded.

    Started by user admin
    Running in Durability level: MAX_SURVIVABILITY
    [Pipeline] Start of Pipeline
    [Pipeline] node
    Running on Jenkins in /root/.jenkins/workspace/pipeline-arrange
    [Pipeline] {
    [Pipeline] sh
    + echo componentA,componentB,componentC,componentD
    + grep -w -o componentA
    [Pipeline] sh
    + echo componentA,componentB,componentC,componentD
    + grep -w -o componentD
    [Pipeline] sh
    + echo componentA,componentB,componentC,componentD
    + grep -w -o componentB
    [Pipeline] sh
    + echo componentA,componentB,componentC,componentD
    + grep -w -o componentC
    [Pipeline] withEnv
    [Pipeline] {
    [Pipeline] stage
    [Pipeline] { (Build componentA)
    [Pipeline] sh
    + echo 'start to build componentA'
    start to build componentA
    [Pipeline] script
    [Pipeline] {
    [Pipeline] build
    Scheduling project: componentA
    Starting building: componentA #13
    [Pipeline] echo
    SUCCESS
    [Pipeline] }
    [Pipeline] // script
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] stage
    [Pipeline] { (Build parallel jobs)
    [Pipeline] parallel
    [Pipeline] { (Branch: Build componentB)
    [Pipeline] { (Branch: Build componentC)
    [Pipeline] stage
    [Pipeline] { (Build componentB)
    [Pipeline] stage
    [Pipeline] { (Build componentC)
    [Pipeline] sh
    [Pipeline] sh
    + echo 'start to build componentB'
    start to build componentB
    [Pipeline] script
    + echo 'start to build componentC'
    start to build componentC
    [Pipeline] {
    [Pipeline] script
    [Pipeline] {
    [Pipeline] build
    Scheduling project: componentB
    [Pipeline] build
    Scheduling project: componentC
    Starting building: componentB #12
    Starting building: componentC #12
    [Pipeline] echo
    SUCCESS
    [Pipeline] }
    [Pipeline] // script
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] }
    [Pipeline] echo
    SUCCESS
    [Pipeline] }
    [Pipeline] // script
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] }
    [Pipeline] // parallel
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] stage
    [Pipeline] { (Build componentD)
    [Pipeline] sh
    + echo 'start to build componentD'
    start to build componentD
    [Pipeline] script
    [Pipeline] {
    [Pipeline] build
    Scheduling project: componentD
    Starting building: componentD #10
    [Pipeline] echo
    SUCCESS
    [Pipeline] }
    [Pipeline] // script
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] }
    [Pipeline] // withEnv
    [Pipeline] }
    [Pipeline] // node
    [Pipeline] End of Pipeline
    Finished: SUCCESS

  5. Log in to CAE and check the component status. If Upgraded is displayed in the Last Change Status/Time column, the component has been upgraded.

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback