1

I'm building a Jenkins setup to automate the our iOS (Xcode) builds.

The flow right now is as follows:

  1. Build is triggered remotely. Passing the app's name, bundle ID, provisioning profile URL (among other data).
  2. Jenkins fetches the latest codebase version from git.
  3. A Python script is run to edit the app's Info.plist file based on the data provided in the trigger. This Python script also installs the provisioning profile using this approach.
  4. Jenkins uses the Xcode Plugin to build the project.

The Xcode Plugin allows you to specify the provisioning profile UUID to use to build the app. The Python file in step 3 gets this UUID. So now what I need is to save that UUID so it's accessible in a normal text form for the Xcode Plugin to use.

I've used the EnvInject Plugin to create and set an environment variable, which works and is usable in the Xcode Plugin's. But I cannot set this environment variable from any script (Python or Shell) while the job is running, it can only be hard-set in the job's configuration page.

Hope someone can help. Thanks!

Community
  • 1
  • 1
Kiran Panesar
  • 3,094
  • 2
  • 22
  • 28
  • 1
    possible duplicate of [How to set Jenkins environment variable from script](http://stackoverflow.com/questions/23785651/how-to-set-jenkins-environment-variable-from-script) – skrrgwasme Aug 15 '14 at 20:10

1 Answers1

0

But I cannot set this environment variable from any script (Python or Shell) while the job is running,

Yes you can.

  • Your Python/Shell script needs to write a value, in format param=value to a predetermined path/to/file.props (with some back-and-forth, this path can be dynamic too).
  • Configure the EnvInject to read from that path/to/file.props
  • So:

    1. Python/Shell runs dynamically and writes to file.
    2. EnvInject reads the file and loads the environment variables, including $param
    3. Your $param is now available for the rest of the job/scripts
Slav
  • 27,057
  • 11
  • 80
  • 104