Show condition attributes in log to simpler condition debugging

Hello,

I would like to see the attributes listed here https://docs.travis-ci.com/user/conditions-v1#integration as json stringified version in the log. This would make it is simpler to create and verify conditions.

Currently it is sometimes based on assumptions what the real value of one of those attributes is. (in case you misunderstand the docu, you are screwed).

Thanks, Markus

You can already see all of them – in build details, in the Requests view, on the commit and pull request links.

Time passes by so fast, I hadn’t had a look into that topic again. But since we are revisiting our pipeline finally, I need to ask again - where to find the information. Since I of course can manually see some values, I am not sure what gets passed to the condition tester for what variable.

Let’s verify this case here, please: https://travis-ci.org/SAP/luigi/builds/660537442/config : line 91
My assumption is, since it is a merge build, I assume the variable head_branch would be master.
With this setting it just never runs.

Could someone please enlight me to make that step only run after a merge or push in master?

And additionally point me to the “you can already see all of them” … since I apparently failed to find the right position for the values that are actually assigned to the variables.

As https://docs.travis-ci.com/user/conditions-v1#integration says, head_branch is only set for pull request builds. The build you linked to is a regular push build.

As per the same link, it is “the head repository branch name” – i.e. the pull request branch.

So the condition repo = SAP/luigi AND branch = master AND head_branch = master will only trigger in a pull request against SAP/luigi@master created from another repo’s master.


(Using the latest pull request in your repo as example:)
You can see repo value on top of the build pane, branch in the build header, head_branch on pull request’s page which is linked to from the build’s header:

2020-03-10 23_43_46-Build #3078 - SAP_luigi - Travis CI

Thank you for the very detailed explanation. I have read it right in the beginning, but my experiment was not working. And possible I just did the equation wrong.

https://travis-ci.org/SAP/luigi/builds/660223331/config
This was the initial test that I did, since I assumed - if head_branch is from pull request it must be empty on master. But maybe it is not empty, but not defined, which could probably be tested like head_branch IS blank or head_branch IS not present. An equation which I haven’t used so far and there are not examples for it.

Conclusion:
Haven’t checked it more deeply, and also the main topic is not solved. But since after revisiting the available variables, there is a simpler solution to my problem.

The simplest final working solution to check if its not a pull request and only on master repository is the as simple as:
if: repo = SAP/luigi AND branch = master AND type = push

I would still like to see a json output of the object used for the validation.

The conditions syntax doesn’t support quotes-as-an-empty-string, unusually enough (it’s explained in the docs though). IS blank is the way to check for an empty value.

I thought about it. An extra block on the config page, probably at the bottom, looks like the most appropriate place.

But since all the values are already present in the UI, it feels a bit redundant – like, only useful to debug the conditions library, not something for regular use.

The only clear benefit from a pre-made JSON that I see is making it unnecessary to write --data argument by hand for travis-conditions invocations.

1 Like