travis-ci / dpl

Dpl (dee-pee-ell) is a deploy tool made for continuous deployment.
MIT License
1.29k stars 367 forks source link

error installing dpl #1248

Closed Indecis1 closed 2 years ago

Indecis1 commented 2 years ago

Hello. I have a spring boot project. I last compiled it 8 days ago, but today I compile it and I have this error when travis want to deploy my project on Heroku.

Log deploy_error

.travis.yml

language: java
jdk:
  - openjdk8
before_install:
  - chmod +x mvnw
  - rvm install 2.7.0
  - rvm use 2.7.0
  - ruby -v
  - gem install dpl --pre

script:
  - mvn clean verify

deploy:
  provider: heroku
  api_key:
    secure: [myEncryptedKey]
  app: [project_name_on_heroku]
  on:
    repo: [repo_name_on_github]
    branch: main
colindean commented 2 years ago

Your screenshot shows that the current Ruby version is 2.4.5. That's the ${travis_internal_ruby}. You might need to set up your deploy step in a separate step kinda like GitLab users do in their .gitlab.yaml:

deploy_staging:
  stage: deploy
  type: deploy
  image: ruby:latest
  script:
  # workaround https://github.com/travis-ci/dpl/issues/1247
  - gem install dpl && gem install faraday -v 1.8.0
  - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_PRODUCTION_API_KEY
  except:
  - schedules
  only:
  - merge_requests

You'll have to translate that to the equivalent in Travis config, though, obviously.

Indecis1 commented 2 years ago

Thanks. My new file .travis.yml

language: java
jdk:
  - openjdk8

env:
  - HEROKU_APP_NAME = [heroku_app_name]

before_install:
  - chmod +x mvnw
script:
  - mvn clean verify
deploy:
  provider: script
  skip_cleanup: true
  script:
    - rvm use $TRAVIS_RUBY_VERSION do script.rb
    - gem install dpl && gem install faraday -v 1.8.0
    - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_PRODUCTION_API_KEY
  on:
    repo: [my_repo_github]
    branch: main

but now I have a new problem error_travis I search in .travis.yml but I don't see any 'ruby'

colindean commented 2 years ago

I don't see how that could be happening, either.

Try replacing $TRAVIS_RUBY_VERSION with 2.7.0 -- the key problem is that Travis' ruby is too old -- that's the error in your original post.

Indecis1 commented 2 years ago

Thanks it works. I change this line

rvm use $TRAVIS_RUBY_VERSION do script.rb
in

- rvm use $TRAVIS_RUBY_VERSION  use 2.7.0