【问题标题】:Run sbt tests in gitlab ci在 gitlab ci 中运行 sbt 测试
【发布时间】:2015-10-24 10:08:20
【问题描述】:

我有一个 play 2.4.x 项目。我想用gitlab做CI。

如何在ci.gitlab.com 中运行测试?

我的gitbal-ci.yml 文件如下所示,但显然是错误的。

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

我得到了错误

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

【问题讨论】:

    标签: sbt gitlab-ci


    【解决方案1】:

    要在基于 Debian 的发行版上安装 sbt,您必须运行以下步骤

    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
    

    有关详细信息,请参阅official sbt documentation

    【讨论】:

      【解决方案2】:

      您可以直接使用SBT 图像。

      gitbal-ci.yml 在我的情况下工作(也处理缓存):

      image: "hseeberger/scala-sbt"
      
      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
      

      来自:Stackoverflow Answer

      【讨论】:

        【解决方案3】:

        另一种解决方案:

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

        【讨论】:

          猜你喜欢
          • 2021-09-28
          • 2014-07-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-10-08
          • 2016-01-01
          相关资源
          最近更新 更多