java 的 Travis CI yml 文件示例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33267878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Example of Travis CI yml file for java
提问by user2371684
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 CI 的新手,但我已将我的 Github 连接到它。我还创建了一个 .travis.yml,我将语言设置为 java。我创建了一个 HelloWorld.java 文件并提交并将其推送到存储库。
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 中,根本没有构建。当我在设置下检查请求时,我看到提交,状态相同“缺少配置”,除了一个声明“构建成功”但当你悬停在它上面时有一个红十字和红色覆盖。
Is my .travis.yml missing a lot of commands and scripts as I have only set the language?
我的 .travis.yml 是否缺少很多命令和脚本,因为我只设置了语言?
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:
我的 mac 上没有安装任何构建系统,如 maven 或类似系统,所以我猜语言设置是不够的。我需要在脚本部分放一些东西,例如:
jdk:
- openjdk6
script:
mvn verify
after_success:
after_failure:
I need also to know what settings could be set for after_success and after_faliure.
我还需要知道可以为 after_success 和 after_faliure 设置哪些设置。
Thanks, Sohail
谢谢,索海尔
回答by Florian Albrecht
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 不是构建工具。它是一个持续集成工具,通常执行您在本地执行的相同构建命令,但在每次推送到 GitHub 后自动执行。
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.
它需要一个活跃的构建机制。嗯,这并不完全正确,但它要求您在script:
尝试构建代码的 Travis CI 主机上可以执行的部分中指定一个有效的命令。当命令的返回码为 0 时,构建被视为成功。否则,它被视为失败。
(This is all really simplified, best would be to read Travis CI documentation, and perhaps some documents about Continous Integration in general).
(这一切都非常简单,最好阅读 Travis CI 文档,也许还有一些关于持续集成的一般文档)。
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:
简而言之:设置您的项目以使用 Maven 或 Gradle 或您最喜欢的构建工具。您应该能够在本地执行mvn clean verify
(使用 Maven 时)。然后,设置你的 .travis.yml:
language: java
sudo: false
script: mvn clean verify
And commit & push it, together with the pom.xml (when using Maven). Now, Travis CI should work like a charm.
并提交和推送它,连同 pom.xml(使用 Maven 时)。现在,Travis CI 应该像魅力一样工作。