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
Situation Awareness
Managed Threat Detection
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

Setting Up the Jenkins and GitLab Environments

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

Prerequisites

  • A new VPC has been created. In this example, the VPC is named vpc-X and the CIDR block is 192.168.0.0/16.
  • An ECS in vpc-X (with CIDR block of 192.168.0.0/16) has been created. The recommended flavors for this ECS are 4 vCPUs and 16 GiB, and it runs Huawei Cloud EulerOS 2.0. An EIP has been bound to the ECS to pull images from the Internet.

Installing Docker of a Specified Version

  1. Log in to the ECS.
  2. Quickly install Docker of the latest version on the device running Huawei Cloud EulerOS 2.0. You can also manually install Docker. For details, see Docker Engine installation.

    dnf install docker

  3. Check whether Docker is installed.

    docker info

Installing and Configuring GitLab

  1. Pull the GitLab image.

    docker pull gitlab/gitlab-ce

  2. Run the container.

    docker run -d -p 443:443 -p 80:80 -p 222:22 --name gitlab --restart always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/var/log/gitlab -v /home/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce

  3. Check the container status.

    docker ps | grep gitlab

  4. Configure gitlab.rb (with the node path of /home/gitlab/config/gitlab.rb). GitLab generates a project URL based on the container's host name (that is, the container ID) when a project is created. However, a fixed URL is required for the GitLab server. To achieve this, you must configure gitlab.rb.

    1. Run the vi command on the node to open /home/gitlab/config/gitlab.rb.
      vi /home/gitlab/config/gitlab.rb
      Add the following content to it:
      external_url 'http://**.**.**.**' //External IP address of the node, for example, EIP
      gitlab_rails['gitlab_ssh_host'] = '**.**.**.**' //External IP address of the node, for example, EIP
      gitlab_rails['gitlab_shell_ssh_port'] = 222 //This port is mapped when the container is started. (222->22)
    2. Save the changes.

  5. Restart the container.

    docker restart gitlab

  6. Use a browser to access ECS EIP:80 and log in to the GitLab service.

    The default username is root, and the initial login password is stored in the /etc/gitlab/initial_root_password directory of the GitLab container.

    You can run the following command to obtain the password:
    docker exec gitlab cat /etc/gitlab/initial_root_password

Installing and Configuring Jenkins

  1. Pull the Jenkins image.

    docker pull jenkins/jenkins:lts

  2. Run the Jenkins container.

    To execute commands like docker build within the container, the container must have the capability of docker in docker (dind). This requires mounting docker.sock and docker to the container.

    docker run -d -p 8000:8080 -p 50000:50000 \
     -v /var/jenkins_home:/var/jenkins_home \
     -v /var/run/docker.sock:/var/run/docker.sock \
     -v /usr/bin/docker:/usr/bin/docker \
     --name myjenkins --privileged=true -u root jenkins/jenkins:lts

  3. Test whether the docker command can be executed in the Jenkins container.

    docker exec myjenkins docker ps
    CAUTION:

    If the error message "docker: error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory" is displayed, run the following command to address this issue:

    docker exec myjenkins sh -c "apt-get update && apt-get install -y libltdl7"

  4. Use a browser to access ECS EIP:8000 and log in to the Jenkins service.

    The default username is root, and the initial login password is stored in the /var/jenkins_home/secrets/initialAdminPassword directory of the container.

    You can run the following command to obtain the password:

    docker exec myjenkins cat /var/jenkins_home/secrets/initialAdminPassword

  5. Install the recommended plugins.

    After the initial configuration is complete, the Jenkins page is displayed.

  6. Install the kubectl command line tool.

    1. Download kubectl to the local PC.

      It is recommended that kubectl be of the same version as the cluster to be used. For details, see kubectl.

      wget https://dl.k8s.io/release/v*.*.*/bin/linux/amd64/kubectl  // v*.*.* specifies the cluster version.
    2. Copy kubectl to the Jenkins container.
      docker cp kubectl myjenkins:/usr/bin/
      docker exec myjenkins chmod +x /usr/bin/kubectl

  7. Configure Jenkins to obtain GitLab code without a password.

    1. Obtain the SSH public key.
      docker exec -it myjenkins ssh-keygen -t rsa

      Press Enter to skip configuring other parameters.

      You do not have to adjust the settings for parameters that are already set to their default values.

      Check the generated public key.

      docker exec myjenkins cat /root/.ssh/id_rsa.pub
    2. Search for SSH in GitLab and add a new key.

    3. Enter an SSH public key.

    4. Save the SSH key.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback