Bitbucket管道-找不到命名的应用程序版本

时间:2019-03-23 11:22:00

标签: bitbucket amazon-elastic-beanstalk bitbucket-pipelines

我正在尝试使用位桶管道将django项目部署到Elasticbeanstalk。

这是我的配置

image: python:3.7.2

pipelines:
  branches:
      master:
        - step:
            script: 
              - pipe: atlassian/aws-elasticbeanstalk-deploy:0.2.5
                variables:
                  AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                  AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                  AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                  APPLICATION_NAME: $APPLICATION_NAME
                  COMMAND: $COMMAND
                  ENVIRONMENT_NAME: $ENVIRONMENT_NAME
                  VERSION_LABEL: ${ENVIRONMENT_NAME}_${BITBUCKET_COMMIT:0:8}_(YYYY-mm-dd_HHMMSS)
                  WAIT: 'true'
              - pip3 install -r requirements.txt
              - python3 manage.py makemigrations
              - python3 manage.py migrate
              - python3 manage.py collectstatic

我收到以下错误:

An error occurred (InvalidParameterValue) when calling the UpdateEnvironment operation: No Application Version named 'production_d095cbe2_YYYY-mm-dd_HHMMSS)' found.

我只是想知道,不是应该用年份和时间范围而不是YYYY-mm-dd_HHMMSS吗?

1 个答案:

答案 0 :(得分:0)

好吧,如果需要日期和时间,可以调用底层linux容器的date函数:

date +"%Y-%m-d_%H%M%S" # displays 2019-03-26_223932

因此,您的bitbucket-piplines.yml应该按照您期望的方式进行写:

图片:python:3.7.2

pipelines:
  branches:
      master:
        - step:
            script: 
              - pipe: atlassian/aws-elasticbeanstalk-deploy:0.2.5
                variables:
                  AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                  AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                  AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                  APPLICATION_NAME: $APPLICATION_NAME
                  COMMAND: $COMMAND
                  ENVIRONMENT_NAME: $ENVIRONMENT_NAME
                  VERSION_LABEL: ${ENVIRONMENT_NAME}_${BITBUCKET_COMMIT:0:8}_$(date +"%Y-%m-d_%H%M%S")
                  WAIT: 'true'
              - pip3 install -r requirements.txt
              - python3 manage.py makemigrations
              - python3 manage.py migrate
              - python3 manage.py collectstatic