I think I ran into a similar problem.
What you can do is have a different pipeline file stored somewhere else. It can be in one place of check or other check together.
You can define methods in this file, and you need to close "return this" so that the beginning Jenkins file can use the second script. Example:
def initialize(){ wrap([$class: 'BuildUser']) { env.buildUserName = "$env.BUILD_USER" env.buildUserId = "$env.BUILD_USER_ID" env.buildUserEmail = "$env.BUILD_USER_EMAIL" } } // Has to exist with 'return this;' in order to be used as library return this;
In the Jenkins file, you can do the following:
def steps node { steps = load 'MyJenkinsPipelineScript.groovy' steps.initialize() }
Based on any environment variables, you can upload different files. Hope this helps.
source share