我正在使用Jenkins和Multibranch Pipeline,AWSCLI和AWSEBCLI为应用程序进行持续部署。通过 ssh 运行时,一切正常,但在 jenkins 上则不然。
应用: - 爪哇8 - 马文 - 夸库斯框架 https://quarkus.io/
詹金斯文件:
tools {
jdk 'jdk_1.8.0'
maven 'Maven'
}
stages {
stage('Environment Configuration') {
steps {
sh 'sudo pip install awscli==1.16.9 awsebcli==3.14.4'
}
stage('Deploy') {
when {
anyOf {
branch 'feature/CD'
}
}
steps {
sh 'zip -r application.zip target Dockerfile'
sh 'aws configure set aws_access_key_id $ACCESS_KEY_DEV --profile eb-cli'
sh 'aws configure set aws_secret_access_key $SECRET_KEY_DEV --profile eb-cli'
sh 'eb deploy'
}
}
}
}
在 SSH 上:
[root]# eb --version
EB CLI 3.14.4 (Python 2.7.5)
[root]# python --version
Python 2.7.5
[root]# aws --version
aws-cli/1.16.9 Python/2.7.5 Linux/3.10.0-862.11.6.el7.x86_64 botocore/1.11.9
[root]# eb deploy
Uploading application/app-9d9c-191122_104206.zip to S3. This may take a while.
Upload Complete.
2019-11-22 13:42:09 INFO Environment update is starting.
2019-11-22 13:42:13 INFO Deploying new version to instance(s).
关于詹金斯:
+ python --version
Python 2.7.5
[Pipeline] sh
+ aws --version
aws-cli/1.16.9 Python/2.7.5 Linux/3.10.0-862.11.6.el7.x86_64 botocore/1.11.9
+ eb deploy
Traceback (most recent call last):
File "/bin/eb", line 5, in <module>
from ebcli.core.ebcore import main
File "/usr/lib/python2.7/site-packages/ebcli/core/ebcore.py", line 21, in <module>
from ebcli.controllers.clone import CloneController
File "/usr/lib/python2.7/site-packages/ebcli/controllers/clone.py", line 17, in <module>
from ..operations import cloneops, commonops, solution_stack_ops
File "/usr/lib/python2.7/site-packages/ebcli/operations/solution_stack_ops.py", line 23, in <module>
from ebcli.operations import commonops, platformops
File "/usr/lib/python2.7/site-packages/ebcli/operations/platformops.py", line 22, in <module>
from semantic_version import Version
ImportError: No module named semantic_version
您的计算机上可能有多个pip
。 pip install awsebcli
应该已经安装了semantic_version
Python包,但是,正如您从发布的堆栈跟踪中看到的那样,找不到它。为了解决这些问题,理想情况下应该使用 virtualenv。如果您只是想要全新安装,Beanstalk 提供了一组脚本供您安装EBCLI,而不会产生任何摩擦。