我都是,
处理github上托管的java项目。 我想在开发和主分支上直接将代码推送到sonatype。
目前只有开发分支有效,因为我跳过了gpg签名
我使用.travis文件夹中的 setting.xml 和我的凭据
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<!-- Maven Central Deployment -->
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
我的 travis.yml 看起来像这样:
language: java
jdk:
- oraclejdk8
script:
- mvn --settings .travis/settings.xml clean verify
deploy:
-
provider: script
script:
- mvn --settings .travis/settings.xml deploy -D gpg.skip -P release
on:
branch: develop
-
provider: script
script:
- mvn --settings .travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.3:set -D newVersion=$TRAVIS_TAG -P release
- .travis/gpg.sh
- mvn clean deploy --settings .travis/settings.xml -D skipTests=true --batch-mode --update-snapshots -P release
on:
tags: true
我的发布配置文件包含所需的部署插件。
我在推送标签/发布时遇到错误(如0.0.2)。我希望这可以使用标记部署版本。
develop分支工作正常,快照正确部署到sonatype repo。
https://github.com/effectus-io/effectus-parent
提前致谢
这是travis日志错误。
The command "mvn --settings .travis/settings.xml clean verify" exited with 0.
Skipping a deployment with the script provider because this branch is not permitted
dpl.0
Fetching: dpl-1.8.31.gem (100%)Fetching: dpl-1.8.31.gem (100%)
Successfully installed dpl-1.8.31
1 gem installed
dpl.1
Installing deploy dependencies
!!! Script support is experimental !!!
Preparing deploy
Cleaning up git repository with `git stash --all`. If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. See https://docs.travis-ci.com/user/deployment/#Uploading-Files.
No local changes to save
dpl.3
Deploying application
No stash found.
/home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:54:in `system': wrong first argument (ArgumentError)
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:54:in `shell'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/provider/script.rb:18:in `push_app'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/provider.rb:146:in `block in deploy'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:41:in `fold'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/provider.rb:146:in `deploy'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:32:in `run'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/lib/dpl/cli.rb:7:in `run'
from /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/dpl-1.8.31/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 :(得分:0)
我的另一种解决方案是使用bintray - &gt; https://bintray.com/ 它提供了一个发布回购与自动gpg签名的罐子。它也与sonatype同步,所以我相信这是一个使用maven的完整解决方案。
pom中的我使用插件自动进行版本控制 - &gt; https://github.com/effectus-io/effectus-parent/blob/master/pom.xml#L299 注意我不是从特拉维斯承诺的!
为了简单起见,我将快照直接保存到sonatype - &gt; https://github.com/effectus-io/effectus-parent/blob/master/.travis.yml#L34
您可以在此处查看我的工作流程 - &gt; https://github.com/effectus-io/effectus-parent/releases/tag/0.0.10
使用gitflow,正常提交开发分支会自动将快照推送到sonatype。使用版本(标记后)将使用maven版本插件触发构建和重新版本,这将从pom中删除SNAPSHOT并部署到bintray。