gitlab-ci.yml 編寫 用于JAVA項目自動編譯

由于貼出來格式Y(jié)AML已經(jīng)不對了铝穷,僅供參考切勿直接復制使用,另外注銷了artifacts配置。


# This file is a template, and might need editing before it works on your project.

---

# Build JAVA applications using Apache Maven (http://maven.apache.org)

# For docker image tags see https://hub.docker.com/_/maven/

#

# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

#

# This template will build and test your projects as well as create the documentation.

#

# * Caches downloaded dependencies and plugins between invocation.

# * Does only verify merge requests but deploy built artifacts of the

#? master branch.

# * Shows how to use multiple jobs in test stage for verifying functionality

#? with multiple JDKs.

# * Uses site:stage to collect the documentation for multi-module projects.

# * Publishes the documentation for `master` branch.

variables:

# This will supress any download for dependencies and plugins or upload messages which would clutter the console log.

# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.

MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"

# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used

# when running from the command line.

# `installAtEnd` and `deployAtEnd`are only effective with recent version of the corresponding plugins.

MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"

# Cache downloaded dependencies and plugins between builds.

cache:

paths:

? ?- /data/tools/maven3/repo

# This will only validate and compile stuff and run e.g. maven-enforcer-plugin.

# Because some enforcer rules might check dependency convergence and class duplications

# we use `test-compile` here instead of `validate`, so the correct classpath is picked up.

.validate: &validate

stage: build

script:

? ?- 'mvn $MAVEN_CLI_OPTS test-compile'

# For merge requests do not `deploy` but only run `verify`.

# See https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

.verify: &verify

stage: test

script:

? ?- 'mvn $MAVEN_CLI_OPTS verify'

only:

? ?- master

# Validate merge requests using JDK7

#validate:jdk7:

#? <<: *validate

#? image: maven:3.3.9-jdk-7

# Validate merge requests using JDK8

validate:jdk8:

<<: *validate

image: maven:3.3.9-jdk-8

# Verify merge requests using JDK7

#verify:jdk7:

#? <<: *verify

#? image: maven:3.3.9-jdk-7

# Verify merge requests using JDK8

verify:jdk8:

<<: *verify

image: maven:3.3.9-jdk-8

# For `master` branch run `mvn deploy` automatically.

# Here you need to decide whether you want to use JDK7 or 8.

# To get this working you need to define a volume while configuring your gitlab-ci-multi-runner.

# Mount your `settings.xml` as `/root/.m2/settings.xml` which holds your secrets.

# See https://maven.apache.org/settings.html

install:jdk8:

# Use stage test here, so the pages job may later pickup the created site.

stage: test

script:

? ?- '/data/tools/maven3/bin/mvn clean package -U install'

only:

? ?- master

# Archive up the built documentation site.

#artifacts:

#paths:

# ? - target/staging

image: maven:3.3.9-jdk-8

deploy:jdk8:

image: busybox:latest

stage: deploy

script:

# Because Maven appends the artifactId automatically to the staging path if you did define a parent pom,

# you might need to use `mv target/staging/YOUR_ARTIFACT_ID public` instead.

#- mv target/staging public

? ?- '/data/tools/maven3/bin/mvn deploy'

dependencies:

? ?- install:jdk8

#artifacts:

#paths:

#- public

only:

? ?- master




最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末竹捉,一起剝皮案震驚了整個濱河市偿枕,隨后出現(xiàn)的幾起案子即碗,更是在濱河造成了極大的恐慌唉俗,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,591評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件娱仔,死亡現(xiàn)場離奇詭異沐飘,居然都是意外死亡,警方通過查閱死者的電腦和手機牲迫,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,448評論 3 392
  • 文/潘曉璐 我一進店門薪铜,熙熙樓的掌柜王于貴愁眉苦臉地迎上來众弓,“玉大人,你說我怎么就攤上這事隔箍∥酵蓿” “怎么了?”我有些...
    開封第一講書人閱讀 162,823評論 0 353
  • 文/不壞的土叔 我叫張陵蜒滩,是天一觀的道長滨达。 經(jīng)常有香客問我,道長俯艰,這世上最難降的妖魔是什么捡遍? 我笑而不...
    開封第一講書人閱讀 58,204評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮竹握,結(jié)果婚禮上画株,老公的妹妹穿的比我還像新娘。我一直安慰自己啦辐,他們只是感情好谓传,可當我...
    茶點故事閱讀 67,228評論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著芹关,像睡著了一般续挟。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上侥衬,一...
    開封第一講書人閱讀 51,190評論 1 299
  • 那天诗祸,我揣著相機與錄音,去河邊找鬼轴总。 笑死直颅,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的怀樟。 我是一名探鬼主播功偿,決...
    沈念sama閱讀 40,078評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼漂佩!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起罪塔,我...
    開封第一講書人閱讀 38,923評論 0 274
  • 序言:老撾萬榮一對情侶失蹤投蝉,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后征堪,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體瘩缆,經(jīng)...
    沈念sama閱讀 45,334評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,550評論 2 333
  • 正文 我和宋清朗相戀三年佃蚜,在試婚紗的時候發(fā)現(xiàn)自己被綠了庸娱。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片着绊。...
    茶點故事閱讀 39,727評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖熟尉,靈堂內(nèi)的尸體忽然破棺而出归露,到底是詐尸還是另有隱情,我是刑警寧澤斤儿,帶...
    沈念sama閱讀 35,428評論 5 343
  • 正文 年R本政府宣布剧包,位于F島的核電站,受9級特大地震影響往果,放射性物質(zhì)發(fā)生泄漏疆液。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,022評論 3 326
  • 文/蒙蒙 一陕贮、第九天 我趴在偏房一處隱蔽的房頂上張望堕油。 院中可真熱鬧,春花似錦肮之、人聲如沸掉缺。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,672評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽攀圈。三九已至,卻和暖如春峦甩,著一層夾襖步出監(jiān)牢的瞬間赘来,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,826評論 1 269
  • 我被黑心中介騙來泰國打工凯傲, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留犬辰,地道東北人。 一個月前我還...
    沈念sama閱讀 47,734評論 2 368
  • 正文 我出身青樓冰单,卻偏偏與公主長得像幌缝,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子诫欠,可洞房花燭夜當晚...
    茶點故事閱讀 44,619評論 2 354

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構建分布式系統(tǒng)中一些常見模式的工具(例如配置管理涵卵,服務發(fā)現(xiàn),斷路器荒叼,智...
    卡卡羅2017閱讀 134,652評論 18 139
  • 其一 大概林明就是這個時候走到門前的昆婿,來時的路上夕陽已經(jīng)完全消失球碉,屆時天邊仍殘留著一小片余暉。上午的時候剛下過雨仓蛆,...
    陸茶茶閱讀 591評論 0 1
  • 周末家里來了兩位親戚睁冬,于是,我們就有了一次共同吃早餐的機會多律。早餐吃的是黑芝麻湯圓痴突,每人一碗,里面加一個雞蛋狼荞。由于早...
    番茄狂想閱讀 617評論 11 9
  • 【帖撒羅尼迦前書4:11】又要立志作安靜人, 辦自己的事, 親手作工, 正如我們從前所吩咐你們的辽装。 相應于上帝所創(chuàng)...
    高橋先生閱讀 2,190評論 0 0