In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to quickly start the lightweight and fast CI tool Drone, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Preface
The company has been using Jenkins as a CI/CD tool, Jenkins is very powerful, it has done almost all the work of CI/CD, and has been applied to the whole team for a long time. But as companies recommend digital, intelligent, and containerized services, some of the drawbacks of Jenkins have been highlighted:
Heavyweight: Jenkins is so fully functional that it can do almost everything. But this is also one of his drawbacks, too heavyweight, sometimes a small change requires a lot of changes, upgrade\ download plug-ins need to restart and so on.
Upgrading is not easy: we will upgrade Jenkins after some security vulnerabilities related to Jenkins have been exposed, but it is not an easy task. All job was lost after upgrade / restart before. Although all of our project configurations are stored in the form of Jenkinsfile, each job needs to be recreated, including permissions for each job. _ (`room` "∠) _
Complex permission control: this is also a major advantage of Jenkins, which can accurately control the permissions of each user, but it takes more time to configure, and permission confusion will occur over a long period of time.
UI interface: this is actually the most complained part, although there are plug-ins such as Blue Ocean to show pipeline, but it has not fundamentally changed its rudimentary UI interface.
So why use Drone?
In fact, after submitting PR on GitHub, most open source projects will use travis-ci to CI and check the submitted code, while if it is a Kubernetes-related project, they will use prow for CI. But travis-ci can only be used for GitHub, and when I was looking for similar projects, Drone came into my vision.
The greatest truths are the simplest. Compared with Jenkins, Drone is much lighter, from the installation and deployment of the application itself to the construction of the pipeline. Because it is integrated with the source code management system, Drone naturally omits the configuration of various account\ permissions, which is directly consistent with the permissions of source code management systems such as gitlab, github and Bitbucket to operate the source code. As it says on its website:
Any Source Code Manager
Drone integrates seamlessly with multiple source code management systems, including GitHub, GitHubEnterprise, Bitbucket, and GitLab.
Any Platform
Drone natively supports multiple operating systems and architectures, including Linux x64, ARM, ARM64 and Windows x64.
Any Language
Drone works with any language, database or service that runs inside a Docker container. Choose from thousands of public Docker images or provide your own.
Drone naturally supports any source management tool, any platform, and any language.
The purpose of writing this article is not to brag about how useful the tool is, but to summarize the various holes needed to build and use drone to help readers get around them.
Statement
In view of the fact that the various pits encountered in using Drone CI are related to the version of Drone, first of all, I declare that the version of Drone I use is 1.1. if you use version 0.8, please make a detour.
Set up Drone
What I want to say here is the first pit encountered in using drone. When I was about to build drone, I Google a lot of related blog. Most of the blog (including some recent English blog above medium.com) recommended installation using docker-compose, and without exception, they all failed. In desperation, I went back to the documentation on the official website and found that many parameters had changed since 1. 0, and it was officially recommended to run Drone as docker.
So read its documentation before using any open source software, and don't start with a blog (including mine), so you can step on a lot of holes!
Here we take gitlab as an example to show the difference between the startup parameters and the actual parameters of the online version:
Use the administrator DRONE_ADMIN=adminDRONE_USER_CREATE=username:admin,admin:true of various blog official website documents to set up the domain name of GitLab, the domain name of GitLab, the domain name of DRONE_GITLAB_URLDRONE_SERVER_HOSTGitLab, the domain name of keyDRONE_GITLAB_CLIENTDRONE_GITLAB_CLIENT_IDGitLab, the Application of keyDRONE_GITLAB_CLIENTDRONE_GITLAB_CLIENT_IDGitLab, the domain name DRONE_HOSTDRONE_GITLAB_SERVER of secretDRONE_GITLAB_SECRETDRONE_GITLAB_CLIENT_SECRETDrone.
The above only lists some of the differences between the official documentation and the online miscarriage version, so be sure to read the official documentation carefully before using it. The command to run drone is attached below:
Docker run\-- volume=/var/run/docker.sock:/var/run/docker.sock\-- volume=/var/lib/drone:/data\-- env=DRONE_GIT_ALWAYS_AUTH=false\-- URL of env=DRONE_GITLAB_SERVER= {your-gitlab-url}\ # gitlab-- id in Application of env=DRONE_GITLAB_CLIENT_ID= {your-gitlab-applications-id}\ # GitLab-- env=DRONE_GITLAB_CLIENT_SECRET= {your-gitlab-applicati-secret} \ # secret in Application of GitLab-- URl of env=DRONE_SERVER_HOST= {your-drone-url}\ # drone-- env=DRONE_SERVER_PROTO=http\-- env=DRONE_TLS_AUTOCERT=false\-- env=DRONE_USER_CREATE=username: {your-admin-username} Administrator of admin:true\ # Drone-- publish=8000:80\-- publish=443:443\-- restart=always\-- detach=true\-- name=drone\ drone/drone:1.1
For more information on the configuration of gitlab Application and the meaning of other parameters of Drone, please refer to the official documentation. Here, only the operation mode of single node is shown.
Core file .drone.yml
To use Drone, simply create a .drone.yml file at the root of the project, which is the configuration file for the Drone build script, which is versioned with the project, and the developer does not need to maintain an additional configuration script. In fact, modern CI programs do this, which is mainly relative to Jekins. Although Jekins also has plug-in support, it still needs to be configured.
It is worth noting that when this file is .drone.yml, due to the excessive use of Kubernetes, a .drone.yaml file is created for the first time, resulting in no way to get the configuration. _ (`room` "∠) _. The YAML engineer hammered the stone.
Here is a .drone.yml of Java, which is a demonstration of fork someone else's project. Remember to change the image repository address in deployment.yaml to your own private repository.
Sample project source code: https://github.com/sunny0826/pipeline-example-maven
Kind: pipelinename: pipeline-example-mavensteps:- name: Maven compile image: maven:3-jdk-7 volumes:-name: cache path: / root/.m2 commands:-mvn clean install- name: build an image image: plugins/docker volumes:-name: docker path: / var/run/docker.sock settings: username: from_secret: docker_user password: from_secret: docker_pass repo: {your- Repo} registry: {your-registry} tags: ${DRONE_BUILD_NUMBER}-name: Kubernetes deployment image: guoxudongdocker/kubectl:v1.14.1 volumes:-name: kube path: / root/.kube commands:-sed-I "sCompact tag deployment.yaml- name ${DRONE_BUILD_NUMBER} / g" deployment.yaml- kubectl apply-f deployment.yaml- name: nail notification image: guoxudongdocker/drone-dingtalk settings: token: From_secret: dingding type: markdown message_color: true message_pic: true sha_link: true when: status: [failure Success] volumes:- name: cache host: path: / tmp/cache/.m2- name: kube host: path: / tmp/cache/.kube/.test_kube- name: docker host: path: / var/run/docker.socktrigger: branch:-master
Note: the above .drone.yml file mounts local .m2 files, kubeconfig files, and docker.sock files into pipeline to achieve maven packaging caching, K8s deployment, and docker caching to improve CI speed. Instead, mounting requires the administrator to check Trusted in the project settings. This operation can only be done by the administrator, and this option is not visible to ordinary users. The administrator is set up when docker is running-- env=DRONE_USER_CREATE=username: {your-admin-username}, admin:true.
When uploading images and nails, you need to add secret to the settings settings at the same time.
Docker_user:docker Warehouse user name
Docker_pass:docker warehouse password
Dingding: nailing robot token
Note that the nail token here is the part of the webhook after https://oapi.dingtalk.com/robot/send?access_token=.
Construction result
After adding the .drone.yml file, submit the code to the master branch to start the CI build
After the end of the CI, you will be notified in the group where the nailing robot belongs.
Plug-in support
As you can see, the image of each step is an image. I developed the Kubernetes and nail notification plug-ins in pipeline above. You can refer to the official documentation for specific development methods, and many official plug-ins are also provided.
Post-build deployment: Kubernetes, helm, scp
Notification after construction: nailing, Email, Slack, Wechat
Drone is still very convenient to use as a whole, and the speed of building and getting started is very fast, but the official documents are not detailed enough, and the Internet is full of various instances of version 0.8, but in fact, the official website has already released version 1.0, and there is no official example project like example, which pulls up the learning curve. Many pits need to be visited by myself, and when I tested drone, I built it hundreds of times, constantly modifying .drone.yml, the commit message looks scary. PR such as example will be contributed to the authorities in the future.
After reading the above, have you mastered how to quickly get started with the lightweight and fast CI tool Drone? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.