简体   繁体   English

使用Travis CI和Maven部署到Appengine,不使用Oauth2

[英]Deploying to Appengine using Travis CI and Maven, without Oauth2

I have my script for Travis CI set up but I am encountering a problem when i perform an mvn appengine:update it is asking me for an oauth2 token, which i can only generate once. 我有Travis CI设置的脚本,但是当我执行mvn appengine:update时遇到问题mvn appengine:update它是在问我oauth2令牌,我只能生成一次。

When i set the plugin to ignore oauth2 = false. 当我设置插件忽略oauth2 = false时。 Maven still requests me to provide an oauth token. Maven仍然要求我提供一个oauth令牌。 What can i do to solve this? 我该怎么做才能解决这个问题?

            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>1.9.20</version>
                <configuration>
                    <oauth2>false</oauth2>
                    <email>${env.CI_DEPLOY_USERNAME}</email>
                    <noCookies>false</noCookies>
                    <passin>true</passin>
                    <buildSystem>maven</buildSystem>
                    <enableJarClasses>false</enableJarClasses>
                </configuration>
            </plugin>

Setting only 仅设置

<oauth2>false</oauth2>

will not solve it, because what happens in the background is that Maven calls AppCfg, and oauth2 is the default, so it will fallback to it. 不会解决它,因为后台发生的事情是Maven调用AppCfg,而oauth2是默认值,因此它将回退到它。 Rather you should specify an alternative, which would be a service-account key file. 相反,您应该指定一个替代方案,它将是一个服务帐户密钥文件。 nickmoorman has explained how to configure Maven for that. nickmoorman已经解释了如何为此配置Maven。 You should extend: 你应该扩展:

<oauth2>false</oauth2>
<additionalParams>
  <additionalParam>--service_account_json_key_file=/path/to/keyfile.json</additionalParam>
</additionalParams>

I have the same issue with maven. 我和maven有同样的问题。 I switched to appcfg.sh script from GAE java sdk (you have to use encrypted vars for GAE_PASS if it is supported by your CI): 我从GAE java sdk切换到appcfg.sh脚本(如果CI支持,则必须使用GAE_PASS的加密变量):

 echo "$GAE_PASS" | $GAE_DIR/appengine-java-sdk-$GAE_VERSION/bin/appcfg.sh -e "$EMAIL" --passin --no_oauth2 update $APPFOLDER

Unfortunately I'm also getting a warning while running this script: 不幸的是,我在运行此脚本时也收到警告:

*********************************************************
OAuth2 is now the default authentication method.
The --no_oauth2 flag will stop working in release 1.9.21.
*********************************************************

Which means this approach will stop working soon. 这意味着这种方法很快就会停止运作。

Update (Nov 2015) I've managed to use OAuth2 in a CI build (Shippable CI) 更新(2015年11月)我设法在CI版本中使用OAuth2(Shippable CI)

echo $GAE_TOKEN > ~/.appcfg_oauth2_tokens_java
chmod 600 ~/.appcfg_oauth2_tokens_java
mvn appengine:update

Where $GAE_TOKEN is content of the ~/.appcfg_oauth2_tokens_java you have locally (run mvn appengine:update in your local environment). 其中$ GAE_TOKEN是本地的〜/ .appcfg_oauth2_tokens_java的内容(在本地环境中运行mvn appengine:update)。 Please, note you need to escape quotes in the .appcfg_oauth2_tokens_java 请注意,您需要在.appcfg_oauth2_tokens_java中转义引号

GAE_TOKEN='{\"credentials\":{\"userNameOnCIServer\":{\"access_token\":\"yourAccessToken\","expiration_time_millis\":1447752301417,\"refresh_token\":\"yourRefreshToken\"}}}'

Also you need to use encrypted variables to protect your tokens in git (if CI server supports it). 您还需要使用加密变量来保护git中的令牌(如果CI服务器支持它)。

The maven plugin will automatically updated expired tokens so you don't need to update the GAE_TOKEN manually every time the token expires. maven插件会自动更新过期的令牌,因此您无需在每次令牌过期时手动更新GAE_TOKEN。

When you set the oauth to false, maven is asking for a token that you will need for the upload to work. 当您将oauth设置为false时,maven会要求您提供上传工作所需的令牌。

That is to be expected. 这是可以预料的。 When you run the maven deploy (or update), you will be required to allow access to your app, then copy that code into the cmd box. 当您运行maven部署(或更新)时,您将需要允许访问您的应用程序,然后将该代码复制到cmd框中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM