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

should be able to use Jenkins Environment Variables (JENKINS_HOME, WORKSPACE) in the properties file path

      I keep my generic project configuration in a properties file which is in a project that is checked into SCM. I would like to be able to update that file in a parent job, and then consume it (via $WORKSPACE/projectname/global.properties). Currently, you have to use the full path to the properties file, which makes my configuration brittle.

          [JENKINS-13096] should be able to use Jenkins Environment Variables (JENKINS_HOME, WORKSPACE) in the properties file path

          Did you try to inject variables after a SCM checkout?
          Check 'Inject environment variables to the build process' in the 'Build environment' section.
          In the properties file path field, you can specify a relative file path to your workspace (and at this step, the workspace is provisioned by your SCM checkout).

          Gregory Boissinot added a comment - Did you try to inject variables after a SCM checkout? Check 'Inject environment variables to the build process' in the 'Build environment' section. In the properties file path field, you can specify a relative file path to your workspace (and at this step, the workspace is provisioned by your SCM checkout).

          Maddy Goss added a comment -

          actually, in this one instance, I am injecting environment variables prior to the scm checkout. (I use it to determine the specific scm revision to check out). ie:

          • parent project/job - checks out the configuration containing the desired scm revision number
          • child projects/jobs - load the configuration pre-scm and use it to specify the revision being checked out
            Hope that helps

          Maddy Goss added a comment - actually, in this one instance, I am injecting environment variables prior to the scm checkout. (I use it to determine the specific scm revision to check out). ie: parent project/job - checks out the configuration containing the desired scm revision number child projects/jobs - load the configuration pre-scm and use it to specify the revision being checked out Hope that helps

          In my approach, Jenkins jobs should be independent.
          Therefore, file paths in 'Prepare job environment' section must be absolute.

          Your need is a pipeline (or build chain) issue.
          And you need to propagate your scm revision.

          I don't have a solution at the moment. I'm looking for an alternative.

          Could let me know how jobs are tied?
          (do you use upstream/downstream feature, the parameterized job parameter or the build result trigger plugin)?

          Gregory Boissinot added a comment - In my approach, Jenkins jobs should be independent. Therefore, file paths in 'Prepare job environment' section must be absolute. Your need is a pipeline (or build chain) issue. And you need to propagate your scm revision. I don't have a solution at the moment. I'm looking for an alternative. Could let me know how jobs are tied? (do you use upstream/downstream feature, the parameterized job parameter or the build result trigger plugin)?

          Any update?

          Gregory Boissinot added a comment - Any update?

          Maddy Goss added a comment -

          In my case I have the following parameters I must follow:
          1) All configuration must be checked into SCM - Therefore I must start off my build cycle with a job that updates the configuration project in the workspace.
          2) All projects (jobs) in our (Nightly) build sweep must checkout and use a single SVN revision. (This is to avoid mid-sweep check-in issues) - Therefore I'm using the EnvInject to load a property file with the desired scm revision and using that in the scm configuration (ie http://repo/trunk/project@$revision_property)

          In order to support this, I need to be able to load the properties file from the workspace (ie $WORKSPACE/globalConfigProject/scm_revision.properties) or at least relative to jenkins home ($JENKINS_HOME/<relative path to workspace>/globalConfigProject/scm_revision.properties). This way I can run the build on any jenkins server node on any host os without having to know the absolute path to the properties file.

          Oh and to answer your question, I'm using the "Build other projects" post build action to kick off the downstream build jobs (from the configuration update job).

          Hope that helps!
          Maddy

          Maddy Goss added a comment - In my case I have the following parameters I must follow: 1) All configuration must be checked into SCM - Therefore I must start off my build cycle with a job that updates the configuration project in the workspace. 2) All projects (jobs) in our (Nightly) build sweep must checkout and use a single SVN revision. (This is to avoid mid-sweep check-in issues) - Therefore I'm using the EnvInject to load a property file with the desired scm revision and using that in the scm configuration (ie http://repo/trunk/project@$revision_property ) In order to support this, I need to be able to load the properties file from the workspace (ie $WORKSPACE/globalConfigProject/scm_revision.properties) or at least relative to jenkins home ($JENKINS_HOME/<relative path to workspace>/globalConfigProject/scm_revision.properties). This way I can run the build on any jenkins server node on any host os without having to know the absolute path to the properties file. Oh and to answer your question, I'm using the "Build other projects" post build action to kick off the downstream build jobs (from the configuration update job). Hope that helps! Maddy

          I'm afraid EnvInject will not be able to resolve your issue.
          EnvInject is able to inject a properties file from the JENKINS_HOME.
          It is also able to inject a properties file from the workspace (but after the SCM checkout).

          It is the scope of the EnvInject plugin.

          Fee free to provide a new contribution (by modifying the EnvInject plugin, by extending envinject/sharedObjects plugins or by making a new plugin).

          Gregory Boissinot added a comment - I'm afraid EnvInject will not be able to resolve your issue. EnvInject is able to inject a properties file from the JENKINS_HOME. It is also able to inject a properties file from the workspace (but after the SCM checkout). It is the scope of the EnvInject plugin. Fee free to provide a new contribution (by modifying the EnvInject plugin, by extending envinject/sharedObjects plugins or by making a new plugin).

            gbois Gregory Boissinot
            javamllama Maddy Goss
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: