首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在运行GitLab CI运行程序时,“混合编辑器版本发布”将过时的代码推到构建服务器上

在运行GitLab CI运行程序时,“混合编辑器版本发布”将过时的代码推到构建服务器上
EN

Stack Overflow用户
提问于 2016-11-17 21:06:34
回答 2查看 448关注 0票数 1

我正在尝试配置我的GitLab CI,以自动构建我的药剂应用程序,并在每次master分支上成功时创建新版本。但是,无论何时部署,都会因为构建服务器上的旧Git存储库而失败。

我的.gitlab-ci.yml配置:

代码语言:javascript
复制
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上的输出(app生成器是蒸馏器):

代码语言:javascript
复制
$ 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运行时,这会失败。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-11-24 19:44:48

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

代码语言:javascript
复制
git branch -f master HEAD

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

票数 2
EN

Stack Overflow用户

发布于 2016-11-23 20:34:38

我也有同样的问题,我不得不使用branch=而不是引用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40665032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档