1

I have a build process defined in F# Fake script. I'm running this build script on a Jenkins node and everything is great.

However, I want to pass some results out of my script to the Jenkins (or any other build server that runs it).

Specifically, I would like to pass several strings to the Jenkins and use them in the next build step (in Jenkins terms) or in the post-build actions to archive artefacts.

How do I do that?

Alex Sorokoletov
  • 3,102
  • 2
  • 30
  • 52

1 Answers1

2

You can use the EnvInject plugin to pass environment variables to further steps in a Jenkins build. It's not the prettiest solution, but you're kind of limited with what you can pass around in Jenkins.

You would need your F# code to write a properties file, then create a subsequent build step in Jenkins using the EnvInject plugin to read from that properties file. See the documentation for further information on the format of the properties file. Basically it's a bunch of KEY=VALUE pairs separated by newlines.

Chad Gilbert
  • 36,115
  • 4
  • 89
  • 97
  • Thank you, Chad. Is there a way without writing properties file? Reason I do not like this approach is you have to add one more step to Jenkins build to just load these values. – Alex Sorokoletov Jun 28 '16 at 20:15
  • That's the only way I've found to do it in Jenkins. A quick googling [shows](http://stackoverflow.com/questions/10625259/how-to-set-environment-variables-in-jenkins) the [same](http://stackoverflow.com/questions/31203816/jenkins-inject-environment-variable) answer [elsewhere](http://stackoverflow.com/questions/21130931/environment-variables-in-jenkins) – Chad Gilbert Jun 28 '16 at 20:17
  • Thanks for the links, I found in one of them we can use system-wide environment variables but that is a nightmare to manage with multiple jobs – Alex Sorokoletov Jun 28 '16 at 20:38