【问题标题】:How to tag a git repo in a bamboo build如何在竹子版本中标记 git repo
【发布时间】:2015-02-06 21:55:16
【问题描述】:

我正在尝试在 Bamboo 构建中标记 ruby​​ gem 的 git repo。我认为在 ruby​​ 中做这样的事情就可以完成这项工作

`git tag v#{current_version}`
`git push --tags`

但问题是回购没有来源。 Bamboo 以某种方式摆脱了origin 有什么线索吗?

【问题讨论】:

    标签: bamboo git-tag


    【解决方案1】:

    是的,如果您导航到作业工作区,您会发现 Bamboo 不会“在后台”执行简单的 git clone,并且远程设置为内部文件路径。

    幸运的是,Bamboo 确实将原始存储库 URL 存储为 ${bamboo.repository.git.repositoryUrl},因此您需要做的就是设置一个指向原始存储库的远程并推送到那里。这是我在基本 Git 存储库和 Stash 中一直使用的,基于内部版本号创建标签。

    git tag -f -a ${bamboo.buildNumber} -m "${bamboo.planName} build number ${bamboo.buildNumber} passed automated acceptance testing." ${bamboo.planRepository.revision}
    git remote add central ${bamboo.planRepository.repositoryUrl}
    git push central ${bamboo.buildNumber}
    git ls-remote --exit-code --tags central ${bamboo.buildNumber} 
    

    最后一行只是在新创建的标签无法读回的情况下导致任务失败。

    编辑:不要试图使用变量 ${bamboo.repository.git.repositoryUrl},因为这不一定指向你工作中签出的 repo。

    还要记住,如果您从多个来源签出,${bamboo.planRepository.repositoryUrl} 指向“源代码签出”任务中的第一个 repo。更具体的网址通过以下方式引用:

    ${bamboo.planRepository.1.repositoryUrl}
    ${bamboo.planRepository.2.repositoryUrl}
    ...
    

    等等。

    【讨论】:

    • Bamboo 似乎没有为您提供任何存储库的密码。你是怎么处理的?
    • 您需要为用户bake在构建服务器上运行设置公钥。
    • 计划配置的存储库选项卡下列出的所有存储库都按照它们从数字 1 开始出现的顺序给出了编号。
    • 要使其工作涉及更多内容,它需要设置 SSH 并让 Bamboo 使用正确的 SSH 密钥,这是almfirst.wordpress.com/tagging-from-bamboo
    • 当我运行它时,它似乎工作正常,直到git push central ${bamboo.buildNumber} 我得到“找不到存储库请求的存储库不存在,或者您没有访问它的权限”。 Bamboo 似乎已经为我的 repo 正确添加了所有 ssh 密钥。对此错误有什么想法吗?
    【解决方案2】:

    我知道这是一个旧线程,但是,我想添加此信息。

    从 Bamboo 6.7 版开始,它具有 Git 存储库标记功能Repository Tag

    您可以将存储库标记任务添加到作业和 Bamboo 变量作为标记名称。 您必须通过应用程序链接集成 Bamboo-Bitbucket。

    【讨论】:

      【解决方案3】:

      好像是竹代理checkout后,origin的远程仓库url设置为file://nothing

      [remote "origin"]
      url = file://nothing
      fetch = +refs/heads/*:refs/remotes/origin/*
      

      这就是为什么我们可以使用git remote set-url 更新网址,或者在我的情况下,我只是创建了一个新别名,这样它就不会破坏现有行为。设置这种方式一定有充分的理由。

      [remote "build-origin"]
      url = <remote url>
      fetch = +refs/heads/*:refs/remotes/build-origin/*
      

      我还注意到使用${bamboo.planRepository.&lt;position&gt;.repositoryUrl} 对我不起作用,因为它在我的计划中定义为https。切换到ssh 工作。

      【讨论】:

        猜你喜欢
        • 2018-11-12
        • 1970-01-01
        • 1970-01-01
        • 2016-02-18
        • 2023-03-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-10
        相关资源
        最近更新 更多