繁体   English   中英

在GitLab CI运行程序中运行时,`mix edeliver build release`将过时的代码推送到服务器中

[英]`mix edeliver build release` push outdated code to build server when running in GitLab CI runner

我正在尝试配置我的GitLab CI,使其每次在master分支上成功通过时自动构建我的Elixir应用并创建新版本。 但是,每当涉及到部署时,都会由于构建服务器上的旧Git存储库而失败。

我的.gitlab-ci.yml配置:

image: 'elixir:1.3.3'
services:
  - postgres

# …

staging:
  stage: deploy
  environment: staging
  tags:
    - elixir
  before_script:
    - mix local.hex --force
    - mix do deps.get, compile
    - 'which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)'
    - eval $(ssh-agent -s)
    - echo "$SSH_DEPLOY_STAGING_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
  script:
    - mix edeliver build release --revision=$CI_BUILD_REF --auto-version=git-revision
    - mix edeliver deploy to staging
  only:
    - master
  cache:
    paths:
      - _build/
      - deps/

edeliver在CI上的输出(应用构建器是Distillery):

$ which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)
/usr/bin/ssh-agent
$ eval $(ssh-agent -s)
Agent pid 373
$ echo "$SSH_DEPLOY_STAGING_KEY" | tr -d '\r' | ssh-add -
Identity added: (stdin) (hauleth@niuniobook)
$ mkdir -p ~/.ssh
$ mix edeliver build release --revision=$CI_BUILD_REF --auto-version=git-revision
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified

BUILDING RELEASE OF ONEMEDICAL APP ON BUILD HOST

-----> Authorizing hosts
-----> Ensuring hosts are ready to accept git pushes
-----> Pushing new commits with git to: app@build.server
-----> Resetting remote hosts to 3faf1d077f95ce7207cac7d14dd25b33d648d710
fatal: Could not parse object '3faf1d077f95ce7207cac7d14dd25b33d648d710'.

A remote command failed on:

  app@build.server

Output of the command is shown above and the command executed
on that host is printed below for debugging purposes:

FAILED with exit status 128:

    set -e
    cd /tmp/edeliver/app/builds
    git reset --hard 3faf1d077f95ce7207cac7d14dd25b33d648d710



ERROR: Build failed: exit code 1

在本地运行mix edeliver build一切运行均正常,但是我找不到为什么通过CI运行时失败的原因。

这里的问题是,GitLab CI如何获取存储库以测试环境。 默认情况下,它使用git fetch策略来获取更改,但不移动分支。 该问题有不同的解决方案,但我使用的是通过以下方式强制将master设置为当前提交:

git branch -f master HEAD

在执行mix edeliver之前。 或者,您可以使用git pull重置为确切的分支名称,而不是master

我也有同样的问题。 我必须使用branch=而不是ref

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM