How to initialize some bash helper function in all bash scripts

36 views
Skip to first unread message

stanle...@servicemax.com

unread,
Feb 3, 2017, 6:07:09 AM2/3/17
to Jenkins Users
Hello, all

I am having a requirement to share some bash script function in nearly all jobs.
Right now I defined them as environment variable, and eval them in jobs as needed.

I was trying to find a more elegant way but got no lucky, for example in some where I can define some bash functions and they will be evaluated for all jobs.

Any suggestion on this?


Thanks

Victor Martinez

unread,
Feb 4, 2017, 7:20:29 AM2/4/17
to Jenkins Users
Off the top of my head:
- Add those files as part of the .bashrc file if you use ssh slaves. Confg Managt tools might help you to configure that accordingly. Although this approach is out of the Jenkins's scope.
- https://wiki.jenkins-ci.org/display/JENKINS/Slave+Setup+Plugin might help you

Cheers

stanle...@servicemax.com

unread,
Feb 4, 2017, 7:27:52 AM2/4/17
to Jenkins Users
Thanks for reply.

Yes, they works, but in both ways, we need some manual configuration on jenkins master/slave, and it makes the maintenance hard if there are quite lot such things.
I am trying to find a way so that it's wholly independent on jenkins master/slave so that even we add a new slaves or recreate the jenkins we don't need to do the configuration again.

Thanks,
Stanley

Victor Martinez

unread,
Feb 4, 2017, 9:11:37 AM2/4/17
to Jenkins Users
Unfortunately, the way I only know to automate those steps is either purely cnf mgmt based, such as: puppet, chef or using some groovy script injecting those slaves setup through the jenkins internal api, but it sounds a bit hacky.

Although, using a build wrapper script might help you out, as long as those jobs run a similar script, then those scripts could be agent agnostic which might help to avoid dependencies. But it depends on your use case of course.

Probably someone else got some other ideas/suggestions.

Cheers

Reply all
Reply to author
Forward
0 new messages