smk
smk

Reputation: 5862

Run sbt tests in gitlab ci

I have a play 2.4.x project. I would like to use gitlab to do CI.

How can I run tests in ci.gitlab.com?

My gitbal-ci.yml file looks like the following but its obviously wrong.

tests:
  script: "apt-get install -y sbt && sbt test"

I get the error

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package sbt

Upvotes: 3

Views: 2669

Answers (3)

pme
pme

Reputation: 14803

You can use directly an SBT image.

This gitbal-ci.yml worked in my case (handles also caching):

image: "sbtscala/scala-sbt:17.0.2_1.6.2_3.1.3"

variables:
  SBT_VERSION: "1.2.8"
  SBT_OPTS: "-Dsbt.global.base=sbt-cache/.sbtboot -Dsbt.boot.directory=sbt-cache/.boot -Dsbt.ivy.home=sbt-cache/.ivy"

cache:
  key: "$CI_BUILD_REF_NAME" # contains either the branch or the tag, so it's caching per branch
  untracked: true
  paths:
    - "sbt-cache/.ivy.cache"
    - "sbt-cache/.boot"
    - "sbt-cache/.sbtboot"
    - "sbt-cache/target"

stages:
  - test

test:
  script:
    - sbt test

This is from: Stackoverflow Answer

Upvotes: 2

P3gg
P3gg

Reputation: 23

Another solution:

 test:
      stage: test
      image: mozilla/sbt
      script:
        - sbt test

Upvotes: 0

stefan.schwetschke
stefan.schwetschke

Reputation: 8932

To install sbt on a Debian based distribution, you have to run the following steps

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
sudo apt-get update
sudo apt-get install sbt

See the official sbt documentation for more details.

Upvotes: 1

Related Questions