windows
AWS官方给了三种配置方法,在如下链接中。
https://docs.aws.amazon.com/codeartifact/latest/ug/maven-gradle.html#gradle-intellij
我主要讲解其中两种方法遇到的问题。
以codeartifact作为存储
1.在cmd中配置Token,在idea的build.gradle中获取。
当在AWS的codeartifact中建好了repository后,右上角点击View connection instructions会有配置教程,但是按照教程操作后发现,在拉取包时,"System.env.CODEARTIFACT_AUTH_TOKEN"始终获取不到token,认证失败。这说明CMD中配好的token在idea中没有获取到。
![](https://img.haomeiwen.com/i27194087/35024f22af8f4c79.png)
解决方案:
如果参照官方教程配置后, 在cmd中执行echo %CODEARTIFACT_AUTH_TOKEN%是输出token的。
此后需要运行“setx CODEARTIFACT_AUTH_TOKEN your-token-value”。这个命令做的事情是exports the variable to the system environment to make it permanent and available to the IDE。
2. 在cmd中配置好aws client,在build.gradle中调用get-authorization-token,每次execute task都生成一个新token。
![](https://img.haomeiwen.com/i27194087/a8883841ce647dab.png)
遇到错误"Cannot run program "aws": CreateProcess error=2, The system cannot find the file specified".
这是因为虽然cmd中已配置了aws client。但是安装过程中并没有自动配置环境变量。所以idea中识别不了。
解决方案:
1.进入cmd,执行where aws找到aws-cli的安装路径,配置到环境变量path中。
![](https://img.haomeiwen.com/i27194087/91f7bcd00f0a0fb9.png)
以s3作为存储
1.在cmd中配置好aws client,在build.gradle中通过环境变量配置accessKey和secrectKey。上传到s3中。
![](https://img.haomeiwen.com/i27194087/a09f80134990bf7b.png)
总结:以上介绍了将开发过程中的artifact部署到codeartifact和s3两种方式。这两种方式aws都支持。
区别是s3只是用来存储。
codeartifact的后边也是存储在s3中,功能如下:
(1)存储到其中的文件经过加密
(2)其可以与市面上的一下public的库集成。比如设置其上流仓库为mavencenter,那么如果当前repository中找不到的包会去maven仓库中找。
(3)可以更好的和aws提供的codedeploy、codebuild、codepipeline更好的集成。
网友评论