Example of Travis CI yml file for java(用于 java 的 Travis CI yml 文件示例)
问题描述
我是 Travis CI 的新手,但我已将我的 Github 连接到它.我还创建了一个 .travis.yml,在其中将语言设置为 java.我创建了一个 HelloWorld.java 文件并提交并将其推送到 repo.
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 中,根本没有构建.当我检查设置下的请求时,我看到提交,状态相同缺少配置",除了一个说明构建已成功创建",但当您将鼠标悬停在它上面时有一个红十字和红色覆盖.
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.
谢谢,苏海尔
推荐答案
Travis CI 不是构建工具.它是一个持续集成工具,通常执行您在本地执行的相同构建命令,但在每次推送到 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.
它需要一个激活的构建机制.好吧,这并不完全正确,但它要求您在 script:
部分中指定一个有效命令,该命令可以在尝试构建您的代码的 Travis CI 主机上执行.当命令的返回码为 0 时,构建被视为 SUCCESS.否则,它被视为失败.
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 文档,也许还有一些关于一般持续集成的文档).
(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 文件示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用于 java 的 Travis CI yml 文件示例
基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01