创建一个生成文件以将文件上传到Travis CI

时间:2018-08-25 07:40:53

标签: python amazon-s3 travis-ci

我正在创建Makefile来安装boto3并将文件从运行MacOS的本地计算机上载到Travis CI。

这是我在Makefile中编写的脚本:

language: python
python:
    - "3.5"
    - "3.6"
clean:
    rm -fr ./public
install:
    - pip install boto3
    - upload_file.py
travis-ci: install

.PHONY: all \
    clean \

这是我的upload_file.py文件:

import os.path
import boto3
s3 = boto3.resource('s3')
s3.meta.client.upload_file('Key', 'bucket name', 'Key')

和我的.travis.yml文件:

sudo: required
dist: trusty
language: python
script:
  - make travis-ci
deploy:
  - provider: s3
    on:
        branch: master
    region: us-west-2
    local_dir: public
    bucket: bucketname
    skip_cleanup: true
    acl: public_read
    access_key_id: xxxx
    secret_access_key:
      secure: xxxx

运行git push时出现此错误:

File "./upload_file.py", line 3, in <module>
    import boto3
ImportError: No module named 'boto3'
make: [install] Error 1 (ignored)The command "make travis-ci" exited with 0.

Deploying application
/home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-s3-1.10.0/lib/dpl/provider/s3.rb:56:in `chdir': No such file or directory @ dir_chdir - public (Errno::ENOENT)
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-s3-1.10.0/lib/dpl/provider/s3.rb:56:in `push_app'
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-1.10.0/lib/dpl/provider.rb:196:in `block in deploy'
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-1.10.0/lib/dpl/cli.rb:41:in `fold'
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-1.10.0/lib/dpl/provider.rb:196:in `deploy'
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-s3-1.10.0/lib/dpl/provider/s3.rb:109:in `deploy'
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-1.10.0/lib/dpl/cli.rb:32:in `run'
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-1.10.0/lib/dpl/cli.rb:7:in `run'
    from /home/travis/.rvm/gems/ruby-2.2.6/gems/dpl-1.10.0/bin/dpl:5:in `<top (required)>'
    from /home/travis/.rvm/gems/ruby-2.2.6/bin/dpl:23:in `load'
    from /home/travis/.rvm/gems/ruby-2.2.6/bin/dpl:23:in `<main>'
failed to deploy

0 个答案:

没有答案