'if: tag IS present' does not work

Hi,

We have following configuration:

...
if: tag IS present

You can see here that Travis build did NOT kick in (even though the last commit is tagged AND on branch master - but I am only checking for tag).

If I trigger the build manually, I am always getting:

Skipped as per condition: IF tag IS present

It does not make much sense to me. What am I doing wrong?
Thanks a lot,

christian

Hey @ribose,

First is this still happening?

Please be sure to check all occurrences of branch filters in your .travis.yml file. Usually, you can have a root branch and a deploy provider.

In general, Travis differentiates between builds initiated by pushing a commit or pull request and builds initiated by pushing a tag.

So what this means is, when you’re pushing a commit with a tag, this will trigger two builds with different conditions, (if you only filter your branch names, the build for the tag won’t get triggered).

This is essentially a safeguard for any other branch to avoid publishing the same files multiple times. The released tag will show under active branches in Travis, and its build will trigger.

2 Likes

thanks @montana this has happened to me before, good explanation overall

Good morning @Montana,

Thanks a lot for taking the time and your detailed answer.

Unfortunately, it is still happening. I was able to manually trigger the build by overwriting the if condition in a custom build:

if: true

I do not filter in any way by branch name. The only condition I have in my .travis.yml file, is the one described above.

Would:

branches:
  only:
    - /^\d+\.\d+\.\d+$/

better work? Instead of my if condition which does NOT work…

No, does not work neither.

Have you tried using a compound build condition? Something like:

if: branch = master OR tag IS present

If I correctly understand your example (kindly correct me if I am wrong), it means: build whether master branch or whether the branch (any) is tagged. Or, in my case, master branch (for a couple of minutes until auto-tagging kicks in) could be untagged.

In such cases, I do not want to build. Only when master branch is tagged. So I could try if: master AND tag IS present. But this will not work as, up to my understanding, you will never have both conditions full-filled (see this post).

Do we have a bug here?

I would reread @native-api’s advice, as this seems like the solution to the issue at hand, can you be a bit more clear on the use case? This could be maybe be approached 2 different ways that I can think of.

Historically in Travis, a tagged build, branch is equal to the tag name so it’s quite plausible your current condition is false.

The logic is as follows, on is a condition for deploy, not for stage, some people get this confused, so what that means is when you have a condition only for deploy: on: and not stage: if:, then obviously stage will be triggered, the virtual machine spins up, and then it figures out that deployment conditions (from on: ) are not fulfilled and the job/s finish without doing anything.

If you don’t want this job to trigger on pull_request, include that in condition, do something like:

if: type != pull_request AND tag IS present

NB: (There are 4 types - Pull request, Regular push, Cron and API.)

1 Like