I'm currently trying to adopt my declarative pipeline in the following way:

I have multiple stages, some apply for all branches, some only for specific names.

What I'm now searching for is a way to get a when condition for the existance of a branch like this:

```
if branch b exist
   checkout branch b
else
   checkout branch a

```

Sadly I haven't found a solution for it. I'm pretty sure there is a way using the **git plugin** though.

There's a [StackOverflow solution](https://stackoverflow.com/questions/19508326/jenkins-git-branch-selection-with-fallback/48579241#comment86569907_48579241) for scripted pipelines, but I can't translate them though.

Can someone help me with this or point me at the right direction?