gpt4 book ai didi

GitLab CI、monorepo 和功能分支

转载 作者:行者123 更新时间:2023-12-03 21:27:52 24 4
gpt4 key购买 nike

我在 GitLab 中有一个使用 Feature Branch 方法的 monorepo。

我想要实现的是启动与包含更改文件的目录相关联的管道部分。所以我的 .gitlab-ci.yml 看起来像:

job1:
stage: build
script:
- ...
only:
changes:
- myparentdir/dir1/*

job2:
stage: build
script:
- ...
only:
changes:
- myparentdir/dir2/*
  • 从 develop 创建一个新分支
  • 在此分支上提交 myparentdir/dir2/test.txt
  • 管道启动每个构建作业!

  • 在使用新功能分支时,GitLab 似乎正在考虑每个文件都已更改。

    你知道任何解决方法吗?

    最佳答案

    Gitlab ci 总是对待 changes对于新分支为真。原因是他们无法决定与什么进行比较。

    what this means is that for the first pipeline of a new branch, everything will be built.



    feature request更多细节。

    但是,有一个相当新的特性,称为 merge requests 的管道。 - 在合并请求上运行一个阶段。 Here是实现 changes 的功能请求与合并请求。它已合并,但我不确定它是否已经发布。 (里程碑是 11.9 - 下一个版本)

    同时,您可以自己实现它 - 您可以添加一个阶段来比较更改(git diff)并决定是否运行下一个阶段:
    .store_diff_from_main: &store_diff_from_main |
    git diff --name-only origin/master...HEAD > "${DIFF_FILE}"
    git diff --name-only HEAD~1 >> "${DIFF_FILE}"

    .skip_stage: &skip_stage_condition |
    echo Checking for changes in ${STAGE_PATHS}, changed files
    # https://coderwall.com/p/gecfwa/git-diff-vs
    cat .diff-from-master
    # also cover merge squash cases
    if ! (cat ${DIFF_FILE} | grep -E "${STAGE_PATHS}"); then
    echo "Skipping stage ..."
    exit 0
    fi

    关于GitLab CI、monorepo 和功能分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55067521/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com