2

I would like to deploy Spring Boot app from gitlab using Gitlab runner to Heroku. I find some tutorials but for ruby.

gitlab-ci.yml

image: maven:3-jdk-8 

before_script:
    - java -version
    - mvn -version

    variables:
      MAVEN_OPTS: "-Dmaven.repo.local=.m2"

cache:
  paths:
    - .m2/

stages:
  - install
  - test
  - deploy

project-install:
  stage: install
  script:
      - mvn install -P gitlab

backend-test:
 stage: test
  script:
      - mvn verify -pl backend -P itTest,gitlab

heroku-deploy:
????

I found maven heroku plugin but my project is under gitlab repository not heroku repository. Moreover i cannot find proper configuration for this plugin. I want to pass login and password via this plugin to connect to heroku.

My current config:

<plugin>
   <groupId>com.heroku.sdk</groupId>
   <artifactId>heroku-maven-plugin</artifactId>
   <version>1.2.0</version>
   <configuration>
       <appName>app-name</appName>
       <processTypes>
           <web>java $JAVA_OPTS -jar target/*.jar</web>
       </processTypes>
   </configuration>
</plugin>

Maybe I could do continuous deployment. Can anyone help?

4
  • what does the heroku-deploy: step look like for the Ruby example? Commented Aug 23, 2017 at 16:45
  • I think you probably want to forget the maven plugin and deploy with Git (as I assume the Ruby example did) Commented Aug 23, 2017 at 19:58
  • Maybe it is solution but i looking for example of this. I am a beginner and everything what i done i placed above. Moreover when deploy ruby app you install some gems and special plugins for deploying ruby not java Commented Aug 24, 2017 at 8:16
  • @codefinger , if you have an idea about this, please post example code Commented Aug 24, 2017 at 8:22

1 Answer 1

1

Guess this would help. This works for spring boot application, where we use ruby 'gem' to deploy the app in heroku.

  1. Replace the "appName" with the Heroku app you already created at your Heroku dashboard.
  2. Also add HEROKU_API_KEY(can be found in heroku) as variable in Gitlab CI/CD settings.

And the maven plugin is NOT needed.

gitlab-ci.yml

stages:
  - build
  - test
  - deploy

maven-build:
  image: maven:3-jdk-8
  stage: build
  script: "mvn package -B"

maven-test:
  image: maven:3-jdk-8
  stage: test
  script: "mvn test -B"

deploy:
  stage: deploy
  image: ruby:latest
  script:
  - apt-get update -qy
  - apt-get install -y ruby-dev
  - gem install dpl
  - dpl --provider=heroku --app=<appName> --api-key=$HEROKU_API_KEY
  only:
  - master
Sign up to request clarification or add additional context in comments.

2 Comments

This first build the package on GitLab, and then builds it again on Heroku. It should first build the package on GitLab, and then push it on Heroku.
How is it possible that I get the error: apt-get : The term 'apt-get' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.