[Experience] based on the jenkins+git+artifactory CICD scheme

Source: Internet
Author: User
Tags svn ssh docker run artifactory ansible playbook

The CICD full name is the continuous integration of continuous delivery, more suitable for fast iteration of the Internet style, and thus widely popular in the Internet circle.

The scheme described in this paper has been applied to a second-tier Internet company in department level. This blog post does not talk about the specific jenkins+git+artifactory how to install the configuration, specific configuration when you need to do Google search on the line.

What are the benefits of CICD's plan? Here are some of them:
1. Unified compilation Mechanism Compile
2. Unified Packaging Mechanism Package
3. Unified Package Management Warehouse Repository
4. Unified Package Deployment Scenario Deployment
4. Facilitate regression regression
5. Easy Expansion Extension
6. Easy Configuration

One of the core of software engineering is to control complexity and avoid introducing human risk factors as much as possible. This ensures high-quality, fast product iterations by avoiding repetitive wheel build-up and increasing the speed of support for your business on-line.

All the code, including the test Code and Development code, is maintained in Git or svn, and Git is now the mainstream, and SVN's code is moving toward Git.

Using Jenkins's SCM plug-in, you can detect changes to the code base, which automatically triggers the compilation module.

In the compilation section, considering the differences in the compilation requirements of different code libraries, we use Docker technology, so that C++/java and other compilation requirements can be met:

Export Success=1
Docker RUN-IDTP--name $JOB _name$build_number-v $ (readlink-m $scm _path1): $SCM _mount1 $DOCKER _img /usr/sbin/sshd-d &&
    ssh_port=$ (Docker port $JOB _name$build_number |grep 22/|awk-f: ' {print $} ') &&A mp Sleep 3 &&
    ssh-p $ssh _port-i ~/.ssh/id_rsa-o stricthostkeychecking=no localhost \
    "pwd && Cat ~ /.BASHRC && Source ~/.BASHRC && cd $scm _mount1 && $MAKE _cmd "&& export success=0

In this case, the uppercase variables are passed in by the Jenkins job, and the lowercase variables need to be defined earlier. $MAKE _cmd is also in the Jenkins job in advance filled in.

After compiling, you need to package, specifically package which files, this need to use a profile Mypackage.json to define:

{"
  default_parameters":
  {
    "Dest_base_path": "/data/app/mypackage/"
  },
  "package_conf":
  {
    "package_name": "MyPackage",
    "SCM": "Git",
    "include_paths": ["common"]
  },
  "install_conf": {
    "Link": [
      {
        "src": "Common",
        "Dest": "$ (Dest_base_path)/common"
      }
    ]
  },
  "Start" : "CD $ (Dest_base_path) &&./op.sh start",
  "Stop": "CD $ (Dest_base_path) &&./op.sh Stop"
}

This format is common for various packages. Package the common folder into a software package in the packages above.

Package_create.py-c mypackage.json-b master-r-S "Test"

This statement means that the master is packaged with the JSON configuration file, the original directory is preserved after packaging, and the package adds a suffix test string.

After packing, the next step is to upload the package to the warehouse:

Package_upload.py-g mygroup-target/data/mypackage_test.tgz-m Artifactory

This one is to upload the package to the Artifactory warehouse.

At this point, compile, package, transfer warehouse to get it done.

The next step is deployment and configuration.

First, deploy:

Deployment is broken down into packages and installations:

Package_download.py-g mygroup-p mypackage_test-v 1.0.1-b master-d. -R Artifactory

This deployment is to download the package from the warehouse to the current directory.

Then the installation:

Package_install.py-p mypackage_test-v 1.0.1-b Master--same

This statement installs the package in the same location as the original one.

Here's an action like locking: Touch a lock file, then perform the appropriate operation, unpack the package, link the file path, and display the installation information.

Finally, the configuration:
Packaged conf support a field: Additional_ops, you can put the replacement configuration file these additional actions in this parameter, such as the test environment and the online environment is two sets, then the replacement operation in this step to make a distinction.

Switch the task of the package, we are put into a ansible playbook inside to operate, the other specifically wrote a blog to elaborate. Here's a quick look:

po.py start

It encapsulates the operation of the switching service.

Next blog post about how to use Jenkins to do QA protection.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.