参考:http://docs.travis-ci.com/user/deployment/和http://docs.travis-ci.com/user/deployment/releases/
我要将我的JAR文件部署到Github,但我不想每次都创建一个标签。 我知道这不是正确的行为,但如果可能,我想这样做。
构建过程运行正常,但是当我使用此travis.yml
文件时:
language: java
deploy:
provider: releases
api-key: "<my_api_key>"
file: "teapot-1.2.5-beta.jar"
skip_cleanup: true
on:
branch: master
我收到了这个错误:
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 Carlos Magno Oliveira de Abreu
Deploying to repo: icemagno/teapot
Current tag is: dpl.3
Deploying application
/home/travis/.rvm/gems/ruby-1.9.3-p551/gems/octokit-3.7.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/icemagno/teapot/releases: 422 - Validation Failed (Octokit::UnprocessableEntity)
Error summary:
resource: Release
code: missing_field
field: tag_name
resource: Release
code: custom
field: tag_name
message: tag_name is not well-formed
resource: Release
code: custom
message: Published releases must have a valid tag // See: https://developer.github.com/v3/repos/releases/#create-a-release
...
failed to deploy
这是基本的部署配置:
language: java
deploy:
provider: releases
api-key: "<my_key_again>"
file: "teapot-1.2.5-beta.jar"
skip_cleanup: true
on:
tags: true
all_branches: true
但我没有创建任何标签,因为我现在不想这样做。
修改
我已经创建了一个标签,现在我需要更改.travis.yml
文件来测试一些配置,而GitHub不允许我更改标签文件上的任何内容(好的,必须这样)cr#p !
答案 0 :(得分:2)
如果可以,我相信您所寻找的内容与I was相同。
基本上将以下内容添加到.travis.yml
:
before_deploy:
- git config --global user.email "builds@travis-ci.com"
- git config --global user.name "Travis CI"
- export GIT_TAG=$TRAVIS_BRANCH-v0.1.$TRAVIS_BUILD_NUMBER
- git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
- git push -q https://<your-api-key>@github.com/<your_name>/<project_name> --tags
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: [redacted]
file:
- "your_file"
on:
tags: false
all_branches: true
branches:
except:
- /^*-v[0-9]/
小心这样做,因为在使用这些特定配置选项时搞乱可能会导致无限的Travis-CI构建循环,这将污染您的构建和标记历史记录,并且不容易清理。