Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

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

Configuring a Pipeline Build Task

Updated on 2024-09-27 GMT+08:00
  • Scenario 1: If a software package is generated using Jenkins, for example, a JAR package, use the software package deployment scenario in the script. During deployment, the built software package is uploaded to the OBS bucket and the ServiceStage component is upgraded.
  • Scenario 2: If an image package is generated using Jenkins, use the image deployment scenario in the script. During deployment, the built image package is uploaded to the SWR image repository and the ServiceStage component is upgraded.

This section uses the scenario where the instance in Configuring a Pipeline Script is a JAR package as an example.

Creating a GitLab Credential

Use the account and password with the GitLab code repository permission to create a credential in Jenkins for pulling GitLab code.

  1. Enter http://{IP address of the Linux VM where Jenkins is installed}:8080 in the address box of the browser to log in to Jenkins.
  2. Choose Manage Jenkins > Jenkins Configuration. In Configuration, select Gitlab.
  3. Click Add under Credentials and select Jenkins.
  4. Configure the GitLab account password and click Add to save the configuration.
  5. Choose Manage Jenkins > Manage Credentials to view the configured credentials.

    The unique ID is used in Configuring a Pipeline Script.

Creating a Pipeline Task

  1. Enter http://{IP address of the Linux VM where Jenkins is installed}:8080 in the address box of the browser to log in to Jenkins.
  2. Click New Item.
  3. Enter the task name, for example, test-upgrade, select Pipeline, and click OK.

Configuring a Build Trigger

  1. Configure the Jenkins build trigger.

    1. Select Build when a change is pushed to GitLab, save the GitLab webhook URL (required when configuring GitLab webhook), and click Advanced in the lower right corner.
    2. Select Filter branches by regex and configure the build task to be triggered after the specified branch is changed. In the example, the branch name is main. Click Generate to generate a secret token and save it. The token will be used for configuring GitLab webhook.

  2. Configure GitLab webhook.

    1. Log in to GitLab and go to the code repository. In the example, the repository name is test. Select Webhooks in settings, and set URL and Secret token to the GitLab webhook URL and secret token obtained in 1.
    2. Deselect Enable SSL verification for SSL verification and click Add webhook.

Configuring a Pipeline Script

A pipeline script is a build command that runs during build. For details about script parameters, see Table 1.

Table 1 Table 1 Pipeline script parameters

Parameter

Mandatory

Type

Description

git_url

Yes

String

Address of the GitLab code repository.

credentials_id

Yes

String

GitLab credential ID configured using the account password. For details, see Creating a GitLab Credential.

branch_name

Yes

String

Name of the GitLab code repository branch.

maven

Yes

String

Path of the executable file for Maven installation, for example, /root/app/maven/apache-maven-3.8.6/bin/mvn.

upgrade_shell

Yes

String

Path for storing the upgrade.sh script on the VM where Jenkins is deployed, for example, /root/jar/upgrade.sh. For details, see upgrade.sh Description.

  1. After the build trigger is configured, select Pipeline script from the drop-down list on the Pipeline tab.
  2. Configure the pipeline script. In the example, the JAR package build scenario is used. The script is as follows:

    Replace the parameters in the script with the actual parameters in your environment.
    node {
        //Code repository address, for example, http://10.95.156.58:8090/zmg/test.git.
        def git_url = '{Code repository address}'
        //GitLab credential ID.
        def credentials_id = '{GitLab credential ID}'
        //Name of the Git code repository branch, for example, main.
        def branch_name = '{Git code repository branch name}'
        //Path of the executable file for Maven installation, for example, /root/app/maven/apache-maven-3.8.6/bin/mvn.
        def maven = '{Path of the executable file for Maven installation}'
        //Path for storing the upgrade.sh script, for example, /root/jar/upgrade.sh.
        def upgrade_shell = '{Path for storing the upgrade.sh script}'
    
        stage('Clone sources') {
            git branch: branch_name, credentialsId: credentials_id, url: git_url
        }
        stage('Build') {
            //Build a JAR package.
            sh "'$maven' clean package -Dmaven.test.failure.ignore=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true"
        }
        stage('upgrade') {
            //Execute the script and use the JAR package uploaded to OBS to upgrade the ServiceStage component. The timeout period is 5 minutes.
            sh "timeout 300s '$upgrade_shell'"
        }
    }
    NOTE:
    • During pipeline script running, upgrade.sh is invoked. For details about the script, see upgrade.sh Description.
    • Set upgrade.sh as an executable file.

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback