0

I'm working on a continuous deployment for an application at work using Jenkins with Multibranch Pipeline, AWSCLI and AWSEBCLI. When running via ssh, everything works fine, but on jenkins don't.

Application: - Java 8 - Maven - Quarkus Framework https://quarkus.io/

Jenkinsfile:

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'
        }
    }
}

}

On 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).

On Jenkins:

+ 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
  • The issue is that one or more Python modules that awsebcli depends upon is not accessible to the Jenkins user but is available to root user since you install them as a sudoer. See https://stackoverflow.com/questions/46244850/python-module-import-error-for-one-user-but-not-the-other. – Dibakar Aditya Nov 22 '19 at 17:25

1 Answers1

0

You probably have multiple pips on your computer. pip install awsebcli is supposed to have installed the semantic_version Python package, however, as you can see from the stack trace you have posted, it couldn't be found. To get around these problems, you should ideally use virtualenv. If you just want a clean installation, Beanstalk provides a set of scripts for you to install EBCLI without any friction.

progfan
  • 2,454
  • 3
  • 22
  • 28