Disable Git resource fetch of existing commits when new pipeline is created


#1

Hello,

It appears that whenever I create a new Concourse pipeline the git resource will always fetch the last commit that existed even before that pipeline was created. I would like to avoid that and have git resource only fetch new commits after the creation of the pipeline. Is this possible?


#2

I can think of two approaches:

  • When a pipeline is created, it is paused. Leave it paused until a new commit appears. This requires manual intervention.
  • If it makes sense for your case, use a new branch for that pipeline. Only commits on that branch will trigger.

#3

Hi marco-m,

I would like to avoid the first approach to wait for a commit before un-pausing the pipeline.

I am actually using a new branch but it still picks up the latest commit and triggers the job. Here’s what the process look like:

  1. New branch is created in git.
  2. New pipeline is created pointing to that new branch. Right after I create that pipeline the git resource triggers and picks up the last commit although the origin of that commit is actually a branch a new branch was created off. No new commits were yet pushed to new branch.

So essentially I end up with two same builds.


#4

If I understand correctly the following happens:

  1. in git, create and push a new branch foo. This branch is created without a commit, so the branch label is still on master, say commit N.
  2. The pre-existing pipeline, watching the master branch, had already built commit N.
  3. You create the new pipeline, watching branch foo. It picks up the current tip of the branch, which happens to be commit N. From here the double build you mention.

At this point, since you don’t want to use the manual unpause approach I suggested before, you have two possibilities:

  1. Before pushing for the first time branch foo, add at least a commit on it. This commit will be built only by the new pipeline and not by the pipeline watching the master branch (as long as you keep the default value and don’t set every on check).
  2. Assuming you know the name of the branch before it is created, create and set the new pipeline before the creation of the branch. You can immediately unpause it. It will stay orange because the git branch doesn’t exist. As soon as the branch appears, the git resource will transition from orange to normal and the pipeline will trigger. Also in this case you need the foo branch to have at least one commit to avoid double build.

If for any reason you cannot enforce that the branch should appear with at least one commit, well, you have to live with the double build. This is not fault of Concourse, it is inevitable due to your workflow, any other CI system would do the same.