Creating files dynamically per branch in Jenkins

Hi,

How can I set up dynamic file creation per branch in Jenkins ?

I have Jenkins project and some gitbucket repository.
For now there are master and develop branches in repo but we could have also some other branches like feature1, feature2, hotfix, etc

In the repository I have folder with python scripts - python/components/
in which there are some scripts - python1.py, python2.py, etc

There is another directory python/wrappers/ in which I’d like to have dynamically created bash scripts like python1.sh, python2.sh, etc (so files with the same name as python scripts in python/components/ but with different extension and with different content, not just simple copies of these python scripts).

It should be done for every branch that will appear in the repository (so this branch needs to be detected somehow, because I will never know exact branch name).

How can I achieve that ?
Thanks in advance for any suggestions.

This post is on the confusing side as it goes all over the place and provides a lot of info.

I think your asking how to create a file with the branch name? You can use the pipeline step writeFile and $BRANCH_NAME to create whatever you want. If that’s not enough for you, or you want to do something more complicated I recommend shelling out to another script.

I think this is something that should work for me. I will try that out. Thanks!