Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34441

Accept Jenkins environment variable in properties file path

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • envinject-plugin
    • None

      I have a properties file called version.properties in the root dir of the project, and I'm trying to read an env var from it and apply it in the build.

      In the current situation when I check "Prepare an environment for the run" then put "version.properties" in the "Properties File Path" it gives me the following error:

      [EnvInject] - Loading node environment variables.
      [EnvInject] - Preparing an environment for the build.
      [EnvInject] - Keeping Jenkins system variables.
      [EnvInject] - Keeping Jenkins build variables.
      [EnvInject] - [ERROR] - The given properties file path 'version.properties' doesn't exist.
      [EnvInject] - [ERROR] - Missing file path was resolved from pattern 'version.properties' .
      

      So, in order to get the build not to fail is by specifying the full workspace path; so something like /var/lib/jenkins/<JOB_NAME>/version.properties

      Instead of typing the full workspace path, I was trying to do the following "$WORKSPACE/version.properties" but unfortunately that results in the same as above because it literally looks for "$WORKSPACE/version.properties" instead of translating what $WORKSPACE is.

      Error looks like this:

      [EnvInject] - [ERROR] - The given properties file path '$WORKSPACE/version.properties' doesn't exist.
      [EnvInject] - [ERROR] - Missing file path was resolved from pattern '$WORKSPACE/version.properties' .
      

            oleg_nenashev Oleg Nenashev
            farahfa Fadi Farah
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: