Total Pageviews

2018/01/09

[GitLab] How to build jar file automatically

Problem
If I hope GitLab can build a jar file when I commit source code, how to do it?
I am using Maven 3.3.3 and JDK 7 in eclipse, and using mvn clean install -Dmaven.test.skip=true to build WAR file in eclipse.

How-To

Step 1. Add .gitlab-ci.yml to the root directory of my project, the content looks like:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
image: maven:3.3.3-jdk-7
    
build:
  stage: build
  script:
   - "mvn clean install -Dmaven.test.skip=true"
  artifacts:
    expire_in: 1 week
    when: on_success
    paths:
    - target/*.jar

Step 2. Add, commit and push .gitlab-ci.yml to GitLab
Step 3. Seeing the status of your pipeline and jobs 


Reference

[1] https://docs.gitlab.com/ce/ci/quick_start/README.html

1 comment:

albertfan2005 said...

This is amazing this took me 10 million hours and you fixed it in 10 lines thank you Albert <333333