Travis设置将RF测试结果上传到FTP

1、搭建FTP服务器

《基于 CentOS 搭建 FTP 文件服务》
可以参考:https://blog.csdn.net/zyw_java/article/details/75212608

2、设置.travis.yml

script:
    ...
    - python -m robot.run -d ../logs -l log.html ../testcase

after_success:
    ...
    - curl -u [user]:[pwd] -T [path]/log.html ftp://ip/pub/

after_failure:
    ...
    - curl -u [user]:[pwd] -T [path]/log.html ftp://ip/pub/

deploy:
    skip_cleanup: true

// 分支有权限上传
on:
    tags: true
    all_branches: true

注意:curl ftp的语句必须展开,如果用变量会出现无法上传的情况。

上述方式将用户名和密码暴露了,可以使用https://docs.travis-ci.com/user/deployment/custom/文档中的方式将用户名和密码隐藏

env:
  global:
  - 'SFTP_USER=[user]'
  - 'SFTP_PASSWORD=[password]'
  - 'SFTP_KEY=[base64-encoded-rsa-key]'
after_success:
- echo "${SFTP_KEY}" | base64 --decode >/tmp/sftp_rsa
- curl --ftp-create-dirs
       -T filepath/filename
       --key /tmp/sftp_rsa
       sftp://${SFTP_USER}:${SFTP_PASSWORD}@example.com/directory/filename

猜你喜欢

转载自blog.csdn.net/shuizhongmose/article/details/90023708