Can you skip a build if there is a tag?

Bret Copeland's Avatar

Bret Copeland

28 Feb, 2015 08:25 PM

I love the ability to build on tags, and to create special deployment rules for tags vs commits, but generally when I push a tag it is accompanied by a commit (which probably just increments a nuget version and has a commit message the same as the tag name). This means two builds are always queued, but I only care about one of them (the tag build), so I manually cancel the other so I don't have to wait on it.

Is there any way to automatically cancel or skip a build for a commit when there is a tag for the same commit also queued? If not, is this a feature you would consider?

I tried using skip_commits with a pattern to match commits like "v1.2.3" but that also seems to cause tags with that pattern to be skipped, so it's not a viable workaround.

  1. Support Staff 1 Posted by Feodor Fitsner on 28 Feb, 2015 08:58 PM

    Feodor Fitsner's Avatar

    So you there are two "similar" builds started when you push a tag? How do you push a tag? What source control/provider is that?

  2. 2 Posted by Bret Copeland on 28 Feb, 2015 09:11 PM

    Bret Copeland's Avatar

    I generally use SourceTree on Windows for .NET projects. It runs this command when it pushes:

    git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin master:master
    

    You can see here the sample app I've been playing with to figure out AppVeyor, and how every time I do a combination commit/tag push, I get two builds (one for the tag, and one for the commit it references).

    I would expect for some people, that behavior is desirable, but for me it serves no purpose, and it would be my preference to disable it. I would think it could be a feature similar to rolling builds where a tag for a commit takes precedence over another build for the same commit.

  3. Support Staff 3 Posted by Feodor Fitsner on 28 Feb, 2015 09:19 PM

    Feodor Fitsner's Avatar

    OK, this is GitHub which is great. Could you check "Recent deliveries" in webhook settings on GitHub? There are probably two calls for each push with tag you do from SourceTree.

    Could you drop here their requests to AV please?

  4. 4 Posted by Bret Copeland on 28 Feb, 2015 09:28 PM

    Bret Copeland's Avatar

    Correct, there are two for each example like that. I did a diff on the JSON payload and they are largely the same, but one is definitely for the tag while the other is for the commit.

    Basically

      "ref": "refs/heads/master",
      "before": "3d3474943f2495329d1c2bfe5144af1132d72a4a",
      "after": "4833a781474f1b88dc56b2dc0444c84ad674bb36",
      "created": false,
      "deleted": false,
      "forced": false,
      "base_ref": null,
      "compare": "https://github.com/bretcope/AppVeyorTest/compare/3d3474943f24...4833a781474f",
      "commits": [
        {
          "id": "4833a781474f1b88dc56b2dc0444c84ad674bb36",
          "distinct": true,
          "message": "v1.0.6 - Remove skip_commits.",
          "timestamp": "2015-02-28T16:03:48-05:00",
          "url": "https://github.com/bretcope/AppVeyorTest/commit/4833a781474f1b88dc56b2dc0444c84ad674bb36",
          "author": {
            "name": "Bret Copeland",
            "email": "[email blocked]",
            "username": "bretcope"
          },
          "committer": {
            "name": "Bret Copeland",
            "email": "[email blocked]",
            "username": "bretcope"
          },
          "added": [
    
          ],
          "removed": [
    
          ],
          "modified": [
            "appveyor.yml"
          ]
        }
      ]
    

    vs

      "ref": "refs/tags/v1.0.6",
      "before": "0000000000000000000000000000000000000000",
      "after": "72d9ce57483d8fc45c2952e67a9607c45209f5b0",
      "created": true,
      "deleted": false,
      "forced": true,
      "base_ref": null,
      "compare": "https://github.com/bretcope/AppVeyorTest/compare/v1.0.6",
      "commits": [
    
      ]
    

    The rest is the same.

  5. 5 Posted by Bret Copeland on 28 Feb, 2015 09:31 PM

    Bret Copeland's Avatar

    I don't see any sensitive data in the post bodies, so here are the complete bodies, which I think you were asking for:

    For the tag:

    {
      "ref": "refs/tags/v1.0.6",
      "before": "0000000000000000000000000000000000000000",
      "after": "72d9ce57483d8fc45c2952e67a9607c45209f5b0",
      "created": true,
      "deleted": false,
      "forced": true,
      "base_ref": null,
      "compare": "https://github.com/bretcope/AppVeyorTest/compare/v1.0.6",
      "commits": [
    
      ],
      "head_commit": {
        "id": "4833a781474f1b88dc56b2dc0444c84ad674bb36",
        "distinct": true,
        "message": "v1.0.6 - Remove skip_commits.",
        "timestamp": "2015-02-28T16:03:48-05:00",
        "url": "https://github.com/bretcope/AppVeyorTest/commit/4833a781474f1b88dc56b2dc0444c84ad674bb36",
        "author": {
          "name": "Bret Copeland",
          "email": "[email blocked]",
          "username": "bretcope"
        },
        "committer": {
          "name": "Bret Copeland",
          "email": "[email blocked]",
          "username": "bretcope"
        },
        "added": [
    
        ],
        "removed": [
    
        ],
        "modified": [
          "appveyor.yml"
        ]
      },
      "repository": {
        "id": 31470551,
        "name": "AppVeyorTest",
        "full_name": "bretcope/AppVeyorTest",
        "owner": {
          "name": "bretcope",
          "email": "[email blocked]"
        },
        "private": false,
        "html_url": "https://github.com/bretcope/AppVeyorTest",
        "description": "",
        "fork": false,
        "url": "https://github.com/bretcope/AppVeyorTest",
        "forks_url": "https://api.github.com/repos/bretcope/AppVeyorTest/forks",
        "keys_url": "https://api.github.com/repos/bretcope/AppVeyorTest/keys{/key_id}",
        "collaborators_url": "https://api.github.com/repos/bretcope/AppVeyorTest/collaborators{/collaborator}",
        "teams_url": "https://api.github.com/repos/bretcope/AppVeyorTest/teams",
        "hooks_url": "https://api.github.com/repos/bretcope/AppVeyorTest/hooks",
        "issue_events_url": "https://api.github.com/repos/bretcope/AppVeyorTest/issues/events{/number}",
        "events_url": "https://api.github.com/repos/bretcope/AppVeyorTest/events",
        "assignees_url": "https://api.github.com/repos/bretcope/AppVeyorTest/assignees{/user}",
        "branches_url": "https://api.github.com/repos/bretcope/AppVeyorTest/branches{/branch}",
        "tags_url": "https://api.github.com/repos/bretcope/AppVeyorTest/tags",
        "blobs_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/blobs{/sha}",
        "git_tags_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/tags{/sha}",
        "git_refs_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/refs{/sha}",
        "trees_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/trees{/sha}",
        "statuses_url": "https://api.github.com/repos/bretcope/AppVeyorTest/statuses/{sha}",
        "languages_url": "https://api.github.com/repos/bretcope/AppVeyorTest/languages",
        "stargazers_url": "https://api.github.com/repos/bretcope/AppVeyorTest/stargazers",
        "contributors_url": "https://api.github.com/repos/bretcope/AppVeyorTest/contributors",
        "subscribers_url": "https://api.github.com/repos/bretcope/AppVeyorTest/subscribers",
        "subscription_url": "https://api.github.com/repos/bretcope/AppVeyorTest/subscription",
        "commits_url": "https://api.github.com/repos/bretcope/AppVeyorTest/commits{/sha}",
        "git_commits_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/commits{/sha}",
        "comments_url": "https://api.github.com/repos/bretcope/AppVeyorTest/comments{/number}",
        "issue_comment_url": "https://api.github.com/repos/bretcope/AppVeyorTest/issues/comments{/number}",
        "contents_url": "https://api.github.com/repos/bretcope/AppVeyorTest/contents/{+path}",
        "compare_url": "https://api.github.com/repos/bretcope/AppVeyorTest/compare/{base}...{head}",
        "merges_url": "https://api.github.com/repos/bretcope/AppVeyorTest/merges",
        "archive_url": "https://api.github.com/repos/bretcope/AppVeyorTest/{archive_format}{/ref}",
        "downloads_url": "https://api.github.com/repos/bretcope/AppVeyorTest/downloads",
        "issues_url": "https://api.github.com/repos/bretcope/AppVeyorTest/issues{/number}",
        "pulls_url": "https://api.github.com/repos/bretcope/AppVeyorTest/pulls{/number}",
        "milestones_url": "https://api.github.com/repos/bretcope/AppVeyorTest/milestones{/number}",
        "notifications_url": "https://api.github.com/repos/bretcope/AppVeyorTest/notifications{?since,all,participating}",
        "labels_url": "https://api.github.com/repos/bretcope/AppVeyorTest/labels{/name}",
        "releases_url": "https://api.github.com/repos/bretcope/AppVeyorTest/releases{/id}",
        "created_at": 1425145511,
        "updated_at": "2015-02-28T21:03:57Z",
        "pushed_at": 1425157437,
        "git_url": "git://github.com/bretcope/AppVeyorTest.git",
        "ssh_url": "git@github.com:bretcope/AppVeyorTest.git",
        "clone_url": "https://github.com/bretcope/AppVeyorTest.git",
        "svn_url": "https://github.com/bretcope/AppVeyorTest",
        "homepage": null,
        "size": 0,
        "stargazers_count": 0,
        "watchers_count": 0,
        "language": "C#",
        "has_issues": true,
        "has_downloads": true,
        "has_wiki": true,
        "has_pages": false,
        "forks_count": 0,
        "mirror_url": null,
        "open_issues_count": 0,
        "forks": 0,
        "open_issues": 0,
        "watchers": 0,
        "default_branch": "master",
        "stargazers": 0,
        "master_branch": "master"
      },
      "pusher": {
        "name": "bretcope",
        "email": "[email blocked]"
      },
      "sender": {
        "login": "bretcope",
        "id": 3608260,
        "avatar_url": "https://avatars.githubusercontent.com/u/3608260?v=3",
        "gravatar_id": "",
        "url": "https://api.github.com/users/bretcope",
        "html_url": "https://github.com/bretcope",
        "followers_url": "https://api.github.com/users/bretcope/followers",
        "following_url": "https://api.github.com/users/bretcope/following{/other_user}",
        "gists_url": "https://api.github.com/users/bretcope/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/bretcope/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/bretcope/subscriptions",
        "organizations_url": "https://api.github.com/users/bretcope/orgs",
        "repos_url": "https://api.github.com/users/bretcope/repos",
        "events_url": "https://api.github.com/users/bretcope/events{/privacy}",
        "received_events_url": "https://api.github.com/users/bretcope/received_events",
        "type": "User",
        "site_admin": false
      }
    }
    

    For the commit:

    {
      "ref": "refs/heads/master",
      "before": "3d3474943f2495329d1c2bfe5144af1132d72a4a",
      "after": "4833a781474f1b88dc56b2dc0444c84ad674bb36",
      "created": false,
      "deleted": false,
      "forced": false,
      "base_ref": null,
      "compare": "https://github.com/bretcope/AppVeyorTest/compare/3d3474943f24...4833a781474f",
      "commits": [
        {
          "id": "4833a781474f1b88dc56b2dc0444c84ad674bb36",
          "distinct": true,
          "message": "v1.0.6 - Remove skip_commits.",
          "timestamp": "2015-02-28T16:03:48-05:00",
          "url": "https://github.com/bretcope/AppVeyorTest/commit/4833a781474f1b88dc56b2dc0444c84ad674bb36",
          "author": {
            "name": "Bret Copeland",
            "email": "[email blocked]",
            "username": "bretcope"
          },
          "committer": {
            "name": "Bret Copeland",
            "email": "[email blocked]",
            "username": "bretcope"
          },
          "added": [
    
          ],
          "removed": [
    
          ],
          "modified": [
            "appveyor.yml"
          ]
        }
      ],
      "head_commit": {
        "id": "4833a781474f1b88dc56b2dc0444c84ad674bb36",
        "distinct": true,
        "message": "v1.0.6 - Remove skip_commits.",
        "timestamp": "2015-02-28T16:03:48-05:00",
        "url": "https://github.com/bretcope/AppVeyorTest/commit/4833a781474f1b88dc56b2dc0444c84ad674bb36",
        "author": {
          "name": "Bret Copeland",
          "email": "[email blocked]",
          "username": "bretcope"
        },
        "committer": {
          "name": "Bret Copeland",
          "email": "[email blocked]",
          "username": "bretcope"
        },
        "added": [
    
        ],
        "removed": [
    
        ],
        "modified": [
          "appveyor.yml"
        ]
      },
      "repository": {
        "id": 31470551,
        "name": "AppVeyorTest",
        "full_name": "bretcope/AppVeyorTest",
        "owner": {
          "name": "bretcope",
          "email": "[email blocked]"
        },
        "private": false,
        "html_url": "https://github.com/bretcope/AppVeyorTest",
        "description": "",
        "fork": false,
        "url": "https://github.com/bretcope/AppVeyorTest",
        "forks_url": "https://api.github.com/repos/bretcope/AppVeyorTest/forks",
        "keys_url": "https://api.github.com/repos/bretcope/AppVeyorTest/keys{/key_id}",
        "collaborators_url": "https://api.github.com/repos/bretcope/AppVeyorTest/collaborators{/collaborator}",
        "teams_url": "https://api.github.com/repos/bretcope/AppVeyorTest/teams",
        "hooks_url": "https://api.github.com/repos/bretcope/AppVeyorTest/hooks",
        "issue_events_url": "https://api.github.com/repos/bretcope/AppVeyorTest/issues/events{/number}",
        "events_url": "https://api.github.com/repos/bretcope/AppVeyorTest/events",
        "assignees_url": "https://api.github.com/repos/bretcope/AppVeyorTest/assignees{/user}",
        "branches_url": "https://api.github.com/repos/bretcope/AppVeyorTest/branches{/branch}",
        "tags_url": "https://api.github.com/repos/bretcope/AppVeyorTest/tags",
        "blobs_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/blobs{/sha}",
        "git_tags_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/tags{/sha}",
        "git_refs_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/refs{/sha}",
        "trees_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/trees{/sha}",
        "statuses_url": "https://api.github.com/repos/bretcope/AppVeyorTest/statuses/{sha}",
        "languages_url": "https://api.github.com/repos/bretcope/AppVeyorTest/languages",
        "stargazers_url": "https://api.github.com/repos/bretcope/AppVeyorTest/stargazers",
        "contributors_url": "https://api.github.com/repos/bretcope/AppVeyorTest/contributors",
        "subscribers_url": "https://api.github.com/repos/bretcope/AppVeyorTest/subscribers",
        "subscription_url": "https://api.github.com/repos/bretcope/AppVeyorTest/subscription",
        "commits_url": "https://api.github.com/repos/bretcope/AppVeyorTest/commits{/sha}",
        "git_commits_url": "https://api.github.com/repos/bretcope/AppVeyorTest/git/commits{/sha}",
        "comments_url": "https://api.github.com/repos/bretcope/AppVeyorTest/comments{/number}",
        "issue_comment_url": "https://api.github.com/repos/bretcope/AppVeyorTest/issues/comments{/number}",
        "contents_url": "https://api.github.com/repos/bretcope/AppVeyorTest/contents/{+path}",
        "compare_url": "https://api.github.com/repos/bretcope/AppVeyorTest/compare/{base}...{head}",
        "merges_url": "https://api.github.com/repos/bretcope/AppVeyorTest/merges",
        "archive_url": "https://api.github.com/repos/bretcope/AppVeyorTest/{archive_format}{/ref}",
        "downloads_url": "https://api.github.com/repos/bretcope/AppVeyorTest/downloads",
        "issues_url": "https://api.github.com/repos/bretcope/AppVeyorTest/issues{/number}",
        "pulls_url": "https://api.github.com/repos/bretcope/AppVeyorTest/pulls{/number}",
        "milestones_url": "https://api.github.com/repos/bretcope/AppVeyorTest/milestones{/number}",
        "notifications_url": "https://api.github.com/repos/bretcope/AppVeyorTest/notifications{?since,all,participating}",
        "labels_url": "https://api.github.com/repos/bretcope/AppVeyorTest/labels{/name}",
        "releases_url": "https://api.github.com/repos/bretcope/AppVeyorTest/releases{/id}",
        "created_at": 1425145511,
        "updated_at": "2015-02-28T21:03:57Z",
        "pushed_at": 1425157437,
        "git_url": "git://github.com/bretcope/AppVeyorTest.git",
        "ssh_url": "git@github.com:bretcope/AppVeyorTest.git",
        "clone_url": "https://github.com/bretcope/AppVeyorTest.git",
        "svn_url": "https://github.com/bretcope/AppVeyorTest",
        "homepage": null,
        "size": 0,
        "stargazers_count": 0,
        "watchers_count": 0,
        "language": "C#",
        "has_issues": true,
        "has_downloads": true,
        "has_wiki": true,
        "has_pages": false,
        "forks_count": 0,
        "mirror_url": null,
        "open_issues_count": 0,
        "forks": 0,
        "open_issues": 0,
        "watchers": 0,
        "default_branch": "master",
        "stargazers": 0,
        "master_branch": "master"
      },
      "pusher": {
        "name": "bretcope",
        "email": "[email blocked]"
      },
      "sender": {
        "login": "bretcope",
        "id": 3608260,
        "avatar_url": "https://avatars.githubusercontent.com/u/3608260?v=3",
        "gravatar_id": "",
        "url": "https://api.github.com/users/bretcope",
        "html_url": "https://github.com/bretcope",
        "followers_url": "https://api.github.com/users/bretcope/followers",
        "following_url": "https://api.github.com/users/bretcope/following{/other_user}",
        "gists_url": "https://api.github.com/users/bretcope/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/bretcope/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/bretcope/subscriptions",
        "organizations_url": "https://api.github.com/users/bretcope/orgs",
        "repos_url": "https://api.github.com/users/bretcope/repos",
        "events_url": "https://api.github.com/users/bretcope/events{/privacy}",
        "received_events_url": "https://api.github.com/users/bretcope/received_events",
        "type": "User",
        "site_admin": false
      }
    }
    
  6. Support Staff 6 Posted by Feodor Fitsner on 28 Feb, 2015 09:36 PM

    Feodor Fitsner's Avatar

    Yeah, the issue is in git push --tags origin master:master command which pushes branch changes together with all tags. GitHub in its turn calls webhook for "regular" branch push and then does one call for each tag in that push; seems tag calls go first.

    If you simply do git push origin [tagname] or create a tag from GitHub UI that will give one webhook call.

    Handling git push --tags is something new - we should think about how to deal with that case.

  7. 7 Posted by Bret Copeland on 28 Feb, 2015 09:51 PM

    Bret Copeland's Avatar

    Well, git push origin [tag] isn't really a solution because then that commit doesn't actually make it into the remote master. At some point, I still have to push to master, and that's what kicks off the unnecessary build.

    My work flow for most projects (regardless of which language or CI I'm using) is to always have a commit in master marked with the version so that when you scan the commit logs, you can easily see where the releases were, and what commits came between them. Generally all that commit does is increment a package number (for nuget/npm/etc), then I tag it and push. That's the exact workflow npm version uses.

    I'm okay that the answer is "we don't support this yet." I can work around it for now by always pushing the tag first so that it will reliably get queued for building first. Long term, it would be great to handle this better.

    I would even accept an ability to specify skip_commits separate from skip_tags, or a way to say skip_commits doesn't apply to tags, as a reasonable solution since I always want to build tags, but may want to skip commits in certain circumstances.

    Thanks for your quick response.

  8. Support Staff 8 Posted by Feodor Fitsner on 28 Feb, 2015 11:13 PM

    Feodor Fitsner's Avatar

    Your flow is perfectly fine and I find git push --tags valid too that must be supported.

    I think we could bet here on the fact that webhook push commit event is fired shortly after tag events. Thus we could skip commit build by doing a check if there was tag commit with the same head commit ID few seconds before.

    We could deploy a fix next week.

  9. Support Staff 9 Posted by Feodor Fitsner on 04 Mar, 2015 01:08 AM

    Feodor Fitsner's Avatar

    Hi Bret,

    I've been experimenting with git push --tags command. Looking at webhook's "Recent deliveries" GitHub calls "push" event for commit first and then for each tag consequently. Could you please take a look at your repo and confirm that this is correct order?

    My concern here is racing condition.

  10. 10 Posted by Bret Copeland on 04 Mar, 2015 02:33 AM

    Bret Copeland's Avatar

    I'm actually seeing the tag hook first most often, but I don't see a consistent order in my logs. Sometimes the tag event is pushed first, and sometimes the commit is first. So I don't think relying on order would work.

  11. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:54 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac