| The issue is in function checkout, at line 721, there is a call to Run.getEnvironment() to get tje environment: however, this does fully not work in pipeline. According to this page:
There is no equivalent to AbstractBuild.getBuildVariables() for WorkflowRun (any Groovy local variables are not accessible as such). Also, WorkflowRun.getEnvironment(TaskListener)is implemented, but only yields the initial build environment, irrespective of withEnv blocks and the like.
To overcome this, I see few options:
- One approach is a dirty hack in workflow-scm-step (in ScmStep.StepExecutionImpl.run()): wrap the actual Run object with a decorator class, which would simply return the actual environment vars (using StepContext.get(EnvVars.class)) when Run.getEnvironment() is called
- A cleaner approach would be to modify the SCM api, so that checkout takes an extra EnvVars parameter: which would be initialized from Run.getEnvironment() is not provided. But this requires changing a core API and the workflow-scm-step plugin...
- Finally, a last approach is to integrate the ssh-agent functionallity directly in the repoScm : specify the credentials directly in the SCM configuration and run the agent automatically when required. This side-steps the problem, by not depending on environment variables, but is probably more complicated (and the environment dependency may still be required in other cases)
Jesse Glick, Andrew Bayer : what do you think about this? any advice? |