简体   繁体   中英

Configuring gitlab-ci.yml for simple java project

I have a simple java project with HelloWorld class , I want to add the GitLab CI/CD for this project by using the .gitlab-ci.yml and runnable configuration files , I am trying to find the reference but am unable to find for simple java project , any help in configuring the above project is appreciated. Thanks Rama

I used this as a simple setup for my .gitlab-ci.yml

build:
  stage: build
  image: openjdk:8-jdk
  script: javac src/javaTest/JavaTest.java
  artifacts:
    untracked: true

https://gitlab.com/peterfromearth/java-test/blob/master/.gitlab-ci.yml

That will build & test your application using gradle :

image: gradle:alpine

stages:
  - build
  - test

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle


build:
  stage: build
  script:
    gradle --build-cache assemble
  artifacts:
    paths:
      - build/libs/*.jar
    expire_in: 1 week

test:
  stage: test
  script:
    gradle check


after_script:
  - echo "End CI"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM