Artifact & GitLab CI continuous integration practice

Posted by cullouch on Wed, 19 Feb 2020 12:26:13 +0100

GitLab CI enables you to create multiple builds and evaluate whether each code submission passes the test and the impact on your product. In the process of building, a large number of binary files will be generated. If these files are not managed correctly on a large scale, the binary file management will be confused. In order to overcome this problem, artifact is seamlessly integrated into the GitLab CI construction process to better publish and manage these binaries, and through JFrog CLI, GitLab CI caches, publishes your dependency packages, artifact packages, and construction information to artifact.

This article describes how to integrate GitLab CI with the artifact to not only parse and deploy binaries, but also Build Integration For more help in.

After integrating artifact with GitLab CI, you can store and view the following information:

  • Building information and publishing modules
  • Dependencies used
  • environment variable
  • License summary
  • Link to your Jira issue
  • Differences between builds

    • Environmental configuration
  • Install Gitlab Runner and configure Gitlab (I won't repeat here)
  • Prepare a sample project

  • Create warehouse (2 local, 1 remote, 1 virtual) in artifact: Maven dev local, Maven Pro local, Maven remote, Maven virtual
  • Write configuration file in project directory (maven.conf)
version: 1

type: maven


  snapshotRepo: maven-virtual

  releaseRepo: maven-virtual

  serverID: Default-Server


  snapshotRepo: maven-virtual

  releaseRepo: maven-virtual

  serverID: Default-Server


Write the configuration file (jira-cli.conf) in the project directory

version: 1


  serverID: Default-Server

  trackerName: JIRA

  regexp: (.+-[0-9]+)\s-\s(.+)

  keyGroupIndex: 1

  summaryGroupIndex: 2


  aggregate: true

  aggregationStatus: RELEASED
  • Configure the environment variables of the factory in gitlab, Settings CI / CD variables, such as:



MAVEN_REPO_KEY maven-virtual

2, Script Gitlab CI and execute build

  • Script in the project directory (. gitlab-ci.yml)
image: docker:git


- docker:dind


- build


  image: maven:3.5.4-jdk-8-alpine

  stage: build


    # Install

    - apk add git

    # Set the M2_HOME environment variable

    - export M2_HOME=/usr/share/maven


    # Download JFrog CLI

    - curl -fL | sh

    # Configure Artifactory instance with JFrog CLI

    - ./jfrog rt config --url=$ARTIFACTORY_URL --user=$ARTIFACTORY_USER --password=$ARTIFACTORY_PASS

    - ./jfrog rt c show


    # Mvn clean install

    - ./jfrog rt mvn "clean install" maven.conf --build-name=gitlabci-maven-artifactory --build-number=$CI_JOB_ID


    # Collect the environment variables

    - ./jfrog rt bce gitlabci-maven-artifactory $CI_JOB_ID


    # Add jira issue

    - ./jfrog rt bag gitlabci-maven-artifactory $CI_JOB_ID --config jira-cli.conf


    # Add sonar(optional)

    - ./jfrog rt sp "maven-dev-local/org/jfrog/test/multi3/3.7-SNAPSHOT/*.war" "qulity.gate.sonarUrl="


    # Add properties(optional)

    - ./jfrog rt sp "maven-dev-local/org/jfrog/test/multi3/3.7-SNAPSHOT/*.war" "deploy.tool=ansible"

    - ./jfrog rt sp "maven-dev-local/org/jfrog/test/multi3/3.7-SNAPSHOT/*.war" "ip="


    # Pass the build information to Artifactory   

    - ./jfrog rt bp gitlabci-maven-artifactory $CI_JOB_ID


    # Promote

    - ./jfrog rt bpr gitlabci-maven-artifactory $CI_JOB_ID maven-pro-local


    # Xray scan(optional)

    - ./jfrog rt bs gitlabci-maven-artifactory $CI_JOB_ID --fail=false


    # Download(optional)

    - ./jfrog rt dl maven-dev-local/org/jfrog/test/multi3/3.7-SNAPSHOT/multi3-3.7-20191213.050538-8.war all-my-frogs/

  when: manual


  • Submit code, enter git commit message in the following format
HAP-1007 - This is a sample issue


  • Execute build (configurable for manual or automatic execution)


  • View build output in Job




  • issue information in the factory (link to Jira address from HAP-1007)



More interesting content please WeChat search official account: jfrogchina

More technology sharing. You can pay attention to the online classroom on February 20: continuous integration practice of artifact & gitlab CI


Course introduction

Now with more and more open-source projects, most developers will refer to a large number of third-party dependencies, and the use frequency of open-source third-party components has increased significantly. Quoting the components developed by the third party brings great convenience to all our developers, reduces a lot of repetitive work, and improves the development efficiency. But at the same time, it also brings us some hidden dangers, because open source does not mean that the software is safe. How to control the security of the third-party package is a problem that enterprises need to pay attention to


Curriculum revenue

This course mainly introduces how JFrog Xray solves the security problems of third-party components.


Current topic

1. Introduction to third party components

2. Introduction to Xray

3. Xray use scenarios and practices


Classroom activities

The lecturers will draw prizes before the end of this session

No. 1: Xiaomi Bluetooth headset

Second place: JFrog new T-shirt

Third place: JFrog new T-shirt



Registration link:

Topics: Operation & Maintenance Maven GitLab git snapshot