Age container continuous delivery tools --- Drone: Drone Use

Previous article has shown how to install Drone, let's look at how to use. Based gogs as git or warehousing.

First, open the address corresponding to the server, enter the login page, enter configuration at boot server administrator account (corresponding gogs is in the account, of course, possible to use other accounts, but some operations may need administrator) to log in, enter into the system.

 

 Click the button to the top right corner of sync, sync git repository, the synchronization finished, the following will list the current gogs in all git repository, through the top of the search box you can search for an item to operate, after the item is found, click to activate the corresponding project behind button, as shown below:

 

Then click on the button to activate the following configurations:

 

 Keep the default general, direct point save button.

When activated, Drone will activate gogs of webhook, monitor code changes, when a code is changed, it will trigger the pipeline Drone.

Here's a look at the configuration pipleline, we have a maven project as an example, to achieve a maven works automatically compiled and then packaged into containers mirroring, and pushed to private storage in containers.

1, first create a maven project, which add their own test code.

2, created in the root directory of the project .drone.yml file, which is in the pipeline configuration file, drone work is relied on to note.

3, the file structure is as follows:

kind: pipeline
name: default
steps:
  *****

 steps in configuration is the entire pipeline every step of the specific operation, we instantiate the first step is to put the project is compiled, configuration is as follows:

steps:
  - name: build
    image: maven:3.6.2-jdk-8
    commands:
      - mvn clean package
    when:
      branch: master
      event: [ push ]

 

name: the name of the current step

image: The image of the container-dependent step name

commands: In the instruction currently executing container

when: the step of triggering the current conditions, provided that where the master branch occurs when a push operation

This step may be performed by mvn do we usually packed instructions, when executed error occurs, Pipeline will be terminated (step any error occurs, the subsequent operation will be terminated)

The second step is to generate and pushed to mirror the mirror storage, the specific configuration is as follows:

Steps: 
  - name: Build 
    Image: Maven:-JDK 3.6.2. 8- 
    Commands: 
      - Clean mvn Package 
    Volumes: 
      - name: mavenrep 
        path: /root/.m2 
    When: 
      Branch: Master 
      Event: [Push] - name: Docker 
    Image: plugins / Docker 
    settings: 
      username: warehousing login user 
      password: password 
      registry: warehousing services address 
      insecure: true whether it is unsafe storage, general http protocol address to be set to true 
      repo: storage path 
      Tags: Latest 
      build_args: 
        - jar_file: * .jar 
    the when: 
      Branch: Master 
      Event: [the Push]
 

 

After the line 12 is for the second step of the configuration, the corresponding parameters can be modified according to their needs.

Special instructions that image: plugin / docker, this is the drone in the plugin, plugin container is also based on the existence of way, settings for the current plug-in needed configuration parameters.

http://plugins.drone.io/ this address is the drone in support of plug-ins (which have a wechat plug-in, notice micro-channel can be achieved).

This configuration a pipeline to be finished, because we need to package docker mirror, so it needs to create a Dockerfile file, as follows:

FROM openjdk:8
ARG JAR_FILE
ADD ${JAR_FILE} app.jar
ENTRYPOINT [ "sh", "-c", "java -jar /app.jar" ]

 The dockerfile is very simple, the first step is to generate a jar and packaged into activated by mirror java command. The key parameter is inside JAR_FILE, which is passed in through build_args above configuration. The other is the mirror image storage, can be used to configure a private harbor warehouse, and then configure the correct account information can be.

 

Guess you like

Origin www.cnblogs.com/dxp909/p/11585904.html