java的Travis CI yml文件示例 [英] Example of Travis CI yml file for java

查看:780
本文介绍了java的Travis CI yml文件示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是特拉维斯CI的新手,但我已将我的Github连接到它。
我还创建了一个.travis.yml,我将语言设置为java。
我创建了一个HelloWorld.java文件并提交并将其推送到回购。

I am new to Travis CI, but I have connected my Github to it. I have also created a .travis.yml where I set the language to java. I have created a HelloWorld.java file and committed and pushed it to the repo.

在Travis中,根本没有构建。当我在设置下检查请求时,我看到了提交,具有相同的状态Missing config,除了一个声明Build created successfully但是当你翻过它时有一个红叉和红色叠加。

In Travis, there is no build at all. When I check requests under settings, I am seeing the commits, with the same status "Missing config", except for one stating "Build created successfully" but that has a red cross and red overlay when you hoover over it.

我的.travis.yml是否缺少很多命令和脚本因为我只设置语言?

Is my .travis.yml missing a lot of commands and scripts as I have only set the language?

我的mac上安装了maven等没有任何构建系统,所以语言设置不足以说明。我需要在脚本部分添加一些内容,例如:

I dont have any build system as maven or the like on my mac installed, so the language setting won't suffice I guess. I need to put something in the script part for example:

jdk:
 - openjdk6
script:
mvn verify
after_success:
after_failure:

我还需要知道可以为after_success和after_faliure设置什么设置。

I need also to know what settings could be set for after_success and after_faliure.

谢谢,
Sohail

Thanks, Sohail

推荐答案

Travis CI不是一个构建工具。它是一个Continous Integration工具,它通常执行你在本地执行的相同构建命令,但是每次推送到GitHub后都会自动执行。

Travis CI is NOT a build tool. It is a Continous Integration tool which usually executes the same build command you would do locally, but automatically after every push to GitHub.

它需要一个活动的构建机制。嗯,这不完全正确,但它要求您在脚本中指定一个有效命令:部分,可以在试图构建代码的Travis CI主机上执行。当命令的返回码为0时,构建被视为SUCCESS。否则,它被视为FAILURE。

It requires a build mechanism being active. Well, that is not totally true, but it requires you to specify a valid command in the script: section that can be executed on the Travis CI host trying to build your code. When the return code of the command is 0, the build is treated as SUCCESS. Otherwise, it is treated as FAILURE.

(这一切都非常简化,最好是阅读Travis CI文档,也许还有一些关于Continous Integration的文档)。

(This is all really simplified, best would be to read Travis CI documentation, and perhaps some documents about Continous Integration in general).

简而言之:设置项目以使用Maven或Gradle或您喜欢的构建工具。您应该能够在本地执行 mvn clean verify (使用Maven时)。然后,设置你的.travis.yml:

In short: Set up your project to use Maven or Gradle or your favourite build tool. You should be able to locally execute mvn clean verify (when using Maven). Then, set up your .travis.yml:

language: java
sudo: false
script: mvn clean verify

并且提交&将它与pom.xml一起推送(使用Maven时)。现在,Travis CI应该像魅力一样。

And commit & push it, together with the pom.xml (when using Maven). Now, Travis CI should work like a charm.

这篇关于java的Travis CI yml文件示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆