我一直试图让Travis-CI在提交被推送到[master]时自动在GitHub Releases上发布它的构建产品。
不幸的是,GitHub Releases需要一个标签才能发布。作为一种解决方案,我试图让Travis自动生成标签并将其应用于提交。但是,每次Travis更新存储库时,都会导致发布失败。
因此,我对当前的设置做错了什么,或者有没有办法做我所描述的。
我的travis.yml:
language: java
before_install: chmod +x gradlew
install: true
matrix:
include:
- jdk: oraclejdk8
script: ./gradlew build
before_deploy:
- git config --global user.email "builds@travis-ci.com"
- git config --global user.name "Travis CI"
- export GIT_TAG=$TRAVIS_BRANCH-0.1.$TRAVIS_BUILD_NUMBER
- git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
- git push -q https://$TAGPERM@github.com/RlonRyan/JBasicX --tags
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: [redacted]
file:
- "build/libs"
- "build/classes/test/output"
on:
tags: false
all_branches: true
env:
global:
secure: [redacted]
样本Travis-CI日志:
Using worker: worker-linux-e7a62211-1.bb.travis-ci.org:travis-linux-1
system_info
Build system information
Build language: java
Build image provisioning date and time
Sun Dec 7 05:49:51 UTC 2014
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
Cookbooks Version
5736160 https://github.com/travis-ci/travis-cookbooks/tree/5736160
GCC version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
LLVM version
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Pre-installed Ruby versions
ruby-1.9.3-p551
Pre-installed Node.js versions
v0.10.33
Pre-installed Go versions
go1.3.3
Redis version
redis-server 2.8.18
riak version
1.4.12
MongoDB version
MongoDB 2.4.12
CouchDB version
couchdb 1.6.1
Neo4j version
1.9.4
Cassandra version
2.0.9
RabbitMQ Version
3.4.2
ElasticSearch version
1.4.0
Installed Sphinx versions
2.0.10
2.1.9
2.2.4
Default Sphinx version
2.1.9
Installed Firefox version
firefox 31.0esr
PhantomJS version
1.9.8
ant -version
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
mvn -version
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T20:58:10+00:00)
Maven home: /usr/local/maven
Java version: 1.7.0_72, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-042stab090.5", arch: "amd64", family: "unix"
gradle -version
------------------------------------------------------------
Gradle 2.0
------------------------------------------------------------
Build time: 2014-07-01 07:45:34 UTC
Build number: none
Revision: b6ead6fa452dfdadec484059191eb641d817226c
Groovy: 2.3.3
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_72 (Oracle Corporation 24.72-b04)
OS: Linux 2.6.32-042stab090.5 amd64
lein1 version
Using JLine for console I/O; install rlwrap for optimum experience.
Leiningen 1.7.1 on Java 1.7.0_72 Java HotSpot(TM) 64-Bit Server VM
lein2 version
Leiningen 2.5.0 on Java 1.7.0_72 Java HotSpot(TM) 64-Bit Server VM
lein version
Leiningen 2.5.0 on Java 1.7.0_72 Java HotSpot(TM) 64-Bit Server VM
git.checkout
0.26s$ git clone --depth=50 --branch=master git://github.com/RlonRyan/JBasicX.git RlonRyan/JBasicX
Cloning into 'RlonRyan/JBasicX'...
remote: Counting objects: 752, done.
remote: Compressing objects: 100% (348/348), done.
remote: Total 752 (delta 376), reused 688 (delta 335)
Receiving objects: 100% (752/752), 1.52 MiB | 0 bytes/s, done.
Resolving deltas: 100% (376/376), done.
Checking connectivity... done.
$ cd RlonRyan/JBasicX
$ git checkout -qf c89668db02576494a8678f8b8a782d87760f769a
Setting environment variables from .travis.yml
$ export TAGPERM=[secure]
$ jdk_switcher use oraclejdk8
Switching to Oracle JDK8 (java-8-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-8-oracle
$ export TERM=dumb
$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
$ javac -version
javac 1.8.0_25
before_install
0.01s$ chmod +x gradlew
install
0.01s$ true
67.24s$ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-2.2.1-bin.zip
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /home/travis/.gradle/wrapper/dists/gradle-2.2.1-bin/88n1whbyjvxg3s40jzz5ur27/gradle-2.2.1-bin.zip to /home/travis/.gradle/wrapper/dists/gradle-2.2.1-bin/88n1whbyjvxg3s40jzz5ur27
Set executable permissions for: /home/travis/.gradle/wrapper/dists/gradle-2.2.1-bin/88n1whbyjvxg3s40jzz5ur27/gradle-2.2.1/bin/gradle
Download https://repo1.maven.org/maven2/junit/junit/4.11/junit-4.11.pom
Download https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom
Download https://repo1.maven.org/maven2/org/hamcrest/hamcrest-parent/1.3/hamcrest-parent-1.3.pom
Download https://repo1.maven.org/maven2/junit/junit/4.11/junit-4.11.jar
Download https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
:compileJavaNote: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processResources
:classes
:jar
:assemble
:compileTestJavaNote: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processTestResources
:testClasses
:test
JTestsX.JTestsX > testCreateMenu STARTED
JTestsX.JTestsX > testCreateMenu PASSED
JTestsX.JTestsX > testCreateDrawing STARTED
JTestsX.JTestsX > testCreateDrawing PASSED
:check
:build
BUILD SUCCESSFUL
Total time: 1 mins 6.792 secs
The command "./gradlew build" exited with 0.
before_deploy.1
0.01s$ git config --global user.email "builds@travis-ci.com"
before_deploy.2
0.01s$ git config --global user.name "Travis CI"
before_deploy.3
0.01s$ export GIT_TAG=$TRAVIS_BRANCH-0.1.$TRAVIS_BUILD_NUMBER
before_deploy.4
0.01s$ git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
before_deploy.5
0.79s$ git push -q https://$TAGPERM@github.com/RlonRyan/JBasicX --tags
dpl.0
Fetching: dpl-1.7.9.gem (100%)
Successfully installed dpl-1.7.9
1 gem installed
dpl.1
Installing deploy dependencies
Fetching: addressable-2.3.6.gem (100%)
Successfully installed addressable-2.3.6
Fetching: multipart-post-2.0.0.gem (100%)
Successfully installed multipart-post-2.0.0
Fetching: faraday-0.9.1.gem (100%)
Successfully installed faraday-0.9.1
Fetching: sawyer-0.6.0.gem (100%)
Successfully installed sawyer-0.6.0
Fetching: octokit-3.7.0.gem (100%)
Successfully installed octokit-3.7.0
5 gems installed
Fetching: mime-types-2.4.3.gem (100%)
Successfully installed mime-types-2.4.3
1 gem installed
dpl.2
Preparing deploy
Logged in as RlonRyan
Deploying to repo: RlonRyan/JBasicX
remote: Counting objects: 23, done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 23 (delta 16), reused 10 (delta 3)
Unpacking objects: 100% (23/23), done.
From git://github.com/RlonRyan/JBasicX
* [new tag] master-0.1.23-2015-01-29 -> master-0.1.23-2015-01-29
* [new tag] master-0.1.26-2015-01-29 -> master-0.1.26-2015-01-29
* [new tag] master-0.1.29-2015-01-29 -> master-0.1.29-2015-01-29
* [new tag] master-0.1.34 -> master-0.1.34
* [new tag] master-0.1.36 -> master-0.1.36
* [new tag] v0.1.0 -> v0.1.0
Current tag is: master-0.1.38
dpl.3
Deploying application
/home/travis/.rvm/gems/ruby-1.9.3-p551/gems/octokit-3.7.0/lib/octokit/client/releases.rb:86:in `initialize': Is a directory - build/libs (Errno::EISDIR)
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/octokit-3.7.0/lib/octokit/client/releases.rb:86:in `new'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/octokit-3.7.0/lib/octokit/client/releases.rb:86:in `upload_asset'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/provider/releases.rb:118:in `block in push_app'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/provider/releases.rb:102:in `each'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/provider/releases.rb:102:in `push_app'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/provider.rb:132:in `block in deploy'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/cli.rb:41:in `fold'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/provider.rb:132:in `deploy'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/cli.rb:32:in `run'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/lib/dpl/cli.rb:7:in `run'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.7.9/bin/dpl:5:in `<top (required)>'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/bin/dpl:23:in `load'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/bin/dpl:23:in `<main>'
failed to deploy
答案 0 :(得分:21)
这个概念没有任何问题,只是部署的文件。
要部署的文件未在.travis.yml
中正确列出,并且gradle构建任务未生成正确的.zip文件。
以下是更新的.travis.yml
:
language: java
install: true
matrix:
include:
- jdk: oraclejdk8
script:
- gradle clean build
- gradle dist
before_deploy:
- git config --global user.email "builds@travis-ci.com"
- git config --global user.name "Travis CI"
- export GIT_TAG=$TRAVIS_BRANCH-0.1.$TRAVIS_BUILD_NUMBER
- git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
- git push -q https://$TAGPERM@github.com/RlonRyan/JBasicX --tags
- ls -R
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: [redacted]
file:
- "README.md"
- "dist/JBasicX-Main-0.1.0.zip"
- "dist/JBasicX-Test Output-0.1.0.zip"
on:
tags: false
all_branches: true
env:
global:
secure: [redacted]
请注意,设置此构建的方式,Travis将为每次提交运行两次,但仅部署第一次。这可能值得进一步研究如何避免。
另外,请注意,如果不正确地实现,即deploy.on:tags = true
,则会创建无限的Travis-CI构建循环。这样的结果不容易清理,并且由于无法删除构建历史记录而在Travis中最为明显。
编辑: 重复构建的解决方案在于Travis-CI将标记推送视为提交的方式。避免这种情况的诀窍是由@ o11c在GitHub上为Travis-CI问题#1532找到的。基本上,人们需要做的是用标记前缀排除分支。
在.travis.yml
中,这等于添加以下内容:
branches:
except:
- /^*-v[0-9]/
对于子孙后代,最终.travis.yml
相当于:
language: java
install: true
matrix:
include:
- jdk: oraclejdk8
script:
- gradle clean build
- gradle dist
before_deploy:
- git config --global user.email "builds@travis-ci.com"
- git config --global user.name "Travis CI"
- export GIT_TAG=$TRAVIS_BRANCH-0.1.$TRAVIS_BUILD_NUMBER
- git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
- git push -q https://$TAGPERM@github.com/RlonRyan/JBasicX --tags
- ls -R
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: [redacted]
file:
- "README.md"
- "dist/JBasicX-Main-0.1.0.zip"
- "dist/JBasicX-Test Output-0.1.0.zip"
on:
tags: false
all_branches: true
branches:
except:
- /^*-v[0-9]/
notifications:
email:
on_success: change
on_failure: change
irc:
channels:
- "irc.esper.net#RlonRyan"
on_success: always
on_failure: always
env:
global:
secure: [redacted]