ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [1]]

记录下今天使用Jenkins部署Flask项目遇到的问题。
项目使用FLASK_CONFIG环境变量切换配置,未指定就使用development开发环境配置,导致上线出错。
于是在项目的docker-compose.yaml添加environment参数指定项目环境。

services:
  flask-example:
    image: xxxxx/flask-example
    ports:
      - "5001:8888"
    environment:
      - FLASK_CONFIG:production

再重新使用Jenkins部署,就出现以下错误:

SSH: Connecting from host [localhost]
SSH: Connecting with configuration [test01] ...
SSH: EXEC: completed after 601 ms
SSH: Disconnecting configuration [test01] ...
ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [1]]

一开始以为是ssh连接服务器有问题,查看/var/log/secure日志有以下报错:

Jul 26 11:53:09 test01 sshd[15210]: Accepted publickey for root from 192.168.1.10 port 6320 ssh2: RSA SHA256:XADGa91Yb7qCDvMyb3eI31KU9hILHts3KTAJvDWAhLM
Jul 26 11:53:09 test01 sshd[15210]: pam_unix(sshd:session): session opened for user root by (uid=0)
Jul 26 11:53:09 test01 sshd[15210]: pam_systemd(sshd:session): Failed to release session: Interrupted system call
Jul 26 11:53:09 test01 sshd[15210]: pam_unix(sshd:session): session closed for user root

重启了sshd服务,还是一样。
然后以为是权限问题,查看目录文件是有传送过去,然后就直接在服务器运行docker-compose up -d部署,出现以下错误:

ERROR: The Compose file './docker-compose.yaml' is invalid because:
services.flask-example.environment contains {"FLASK_CONFIG": "production"}, which is an invalid type, it should be a string

到此,才发现是自己的大意,环境变量设置要使用=,而我使用了:。修改完后在Jenkins上就正常部署了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容