1

我正在尝试使用 bitbucket 管道在 heroku 中进行部署,并使用 spring-boot 创建了一个简单的 Web 应用程序。

我想知道你们中是否有人对“bitbucket-pipelines.yml”文件中需要它有什么想法?这是我第一次使用带有 bitbucket 管道的 heroku,我很迷茫。

我的文件看起来像这样:

image: maven:3.3.9   
clone:
  depth: full

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - mvn -B clean install -P heroku # -B batch mode makes Maven less verbose
          - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
4

2 回答 2

1

我会推荐以下步骤:

  1. 遵循Bitbucket Pipelines 文档中部署到 Heroku中提到的步骤 1 。

  2. 请使用以下内容编辑您的“bitbucket-pipelines.yml”文件:

    image: maven:3.3.9
    clone:
      depth: full
    pipelines:
      default:
        - step:
          script:
            - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
            - mvn clean package
            - kill -9 $(lsof -t -i:<your_app_port_number> -sTCP:LISTEN)
            - java -jar target/<your-app-name>.jar &
    

笔记:

  1. < your_app_port_number >< your-app-name >替换为适当的值。

  2. 请记住使用在线验证器检查您的“bitbucket-pipelines.yml”文件。

于 2017-06-02T07:07:56.270 回答
0

这是我bitbucket-pipelines.yml指定弹簧配置文件的位置。

image: maven:3.3.9

clone:
  depth: full

pipelines:
  default:
    - step:
        name: Deploy to Heroku
        deployment: test   # set to test, staging or production
        script:
          - mvn -B clean package -Dspring.profiles.active=prod # -B batch mode makes Maven less verbose
          - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD

我有一个Profile
web: java -Dserver.port=$PORT $JAVA_OPTS -Dspring.profiles.active=prod -jar target/my-api-1.0.0-SNAPSHOT.jar

确保您已在 BitBucket 上配置了 $HEROKU_API_KEY 和 $HEROKU_APP_NAME,例如: 在此处输入图像描述

于 2019-01-26T12:33:31.097 回答