My Jenkins master doesn't have an executor and it can't have due to the design of Jenkins we have in our company. We have 2 worker node. When I add Pipeline shared library then by default Jenkins tries to checkout in master and fails due to obvious reasons as it can't find git
as it is not available in Jenkins master.
Cloning repository git@github.com:Test/jenkins-pipeline-shared.git
> git init /var/lib/jenkins/workspace/rp-pipe_PR-675@libs/slackNotify # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /var/lib/jenkins/workspace/rp-pipe_PR-675@libs/slackNotify
I don't understand why Jenkins can even try to checkout shared library in master because master doesn't even have an executor.
I looked at other people's opinion but my things stop at the point it tries to checkout. How can I get over this? I thought to keep my shared library groovy file in the same repo and import the library into JenkinsFile but seems like it is also not working for me. I tried this but Jenkins couldn't identify modules
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 14: Expected a step @ line 14, column 17.
modules.sendNotifications = load "vars/sendNotifications.groovy"
I tried libraryResource ('vars/sendNotifications.groovy')
but it's not working. Jenkins just fails without throwing any error.
Solution which I think but don't know how to implement :
- Checkout pipeline library in the node where my job is suppose to run
- Ignore pipeline library and create a groovy file in the same repo and import that in the JenkinsFile