• Pipeline support in EnvInject

      EnvInject does not support Pipeline now. Though there are many workarounds, it would be useful to address particular integration use-cases

          [JENKINS-42614] Pipeline support in EnvInject

          Oleg Nenashev added a comment -

          basil What exactly are you missing in EnvInject plugin to make URLTrigger working? The most of API has been already adapted, so it should be possible to migrate the plugins

          Oleg Nenashev added a comment - basil What exactly are you missing in EnvInject plugin to make URLTrigger working? The most of API has been already adapted, so it should be possible to migrate the plugins

          Basil Crow added a comment -

          Hi oleg_nenashev, I don't think I am missing anything. Thanks for addressing this! I have now posted two pull requests in order to add pipeline support to the URL Trigger plugin, using envinject-api 1.2 in order to do so.

          Basil Crow added a comment - Hi oleg_nenashev , I don't think I am missing anything. Thanks for addressing this! I have now posted two pull requests in order to add pipeline support to the URL Trigger plugin, using envinject-api 1.2 in order to do so.

          Oleg Nenashev added a comment -

          Unfortunately I will not have time to work on EnvInject issues for a while. I decided to unassign all issues so that somebody can take them and finalize.

          Context: The plugin has been waiting for adoption for ~2 years. During all this time I was trying to keep this plugin afloat by reviewing the incoming pull requests, fixing defects and keeping the codebase up to date to simplify the handover. But I have not been using this plugin on my own so that such maintenance was a bit lame. I invite all active users to contribute to the plugin by taking ownership of this plugin and of EnvInject API. I am happy to provide any required knowledge transfers and do some assistance during the first months of maintenance

          Oleg Nenashev added a comment - Unfortunately I will not have time to work on EnvInject issues for a while. I decided to unassign all issues so that somebody can take them and finalize. Context: The plugin has been waiting for adoption for ~2 years. During all this time I was trying to keep this plugin afloat by reviewing the incoming pull requests, fixing defects and keeping the codebase up to date to simplify the handover. But I have not been using this plugin on my own so that such maintenance was a bit lame. I invite all active users to contribute to the plugin by taking ownership of this plugin and of EnvInject API. I am happy to provide any required knowledge transfers and do some assistance during the first months of maintenance

          As per description, there are multiple workarounds. Can anybody put link to workaround page, or mention some workarounds here?

          Swanand Gajendragadkar added a comment - As per description, there are multiple workarounds. Can anybody put link to workaround page, or mention some workarounds here?

          Charles Choi added a comment - - edited

          In pipeline "Properties Content",Path=$Path;$JAVA
          bin;C:
          Program Files (x86)\\PuTTY;C:\\NGS\\bin;C:\\Python27;C:
          Python27
          Scripts

          $Path is not evaluated.

          How to "Inject environment variables" using pipeline syntax?

          I would like to see workarounds documentation.

          Charles Choi added a comment - - edited In pipeline "Properties Content",Path=$Path;$JAVA bin;C: Program Files (x86)\\PuTTY;C:\\NGS\\bin;C:\\Python27;C: Python27 Scripts $Path is not evaluated. How to "Inject environment variables" using pipeline syntax? I would like to see workarounds documentation.

          Alex Z added a comment - - edited

          Pass text-yaml variable to job:

          like

          EXTRA_VARIABLES_YAML:

          variabl1: value1

          then, merge extra data into job env:

          def mergeEnv(envVar, extraVars) {
           try {
           def extraParams = readYaml text: extraVars
           for(String key in extraParams.keySet()) {
           envVar[key] = extraParams[key]
           println("Parameter ${key} is updated from EXTRA vars.")
           }
           } catch (Exception e) {
          println("Can't update env parameteres, because: ${e.toString()}")
           }
          }
          
           
          
          extraVarsYAML = env.EXTRA_VARIABLES_YAML.trim() ?: ''
          if (extraVarsYAML) {
          mergeEnv(env, extraVarsYAML)
           extraVars = readYaml text: extraVarsYAML
          } else {
           extraVars = [:]
          }
          
          

          Alex Z added a comment - - edited Pass text-yaml variable to job: like EXTRA_VARIABLES_YAML: variabl1: value1 then, merge extra data into job env: def mergeEnv(envVar, extraVars) { try { def extraParams = readYaml text: extraVars for(String key in extraParams.keySet()) { envVar[key] = extraParams[key] println("Parameter ${key} is updated from EXTRA vars.") } } catch (Exception e) { println("Can't update env parameteres, because: ${e.toString()}") } }   extraVarsYAML = env.EXTRA_VARIABLES_YAML.trim() ?: '' if (extraVarsYAML) { mergeEnv(env, extraVarsYAML) extraVars = readYaml text: extraVarsYAML } else { extraVars = [:] }

          Paul added a comment -

          What's the current workaround for this? I need to be able to inject env vars from a file in my pipeline script, whther its with this plugin or something else?

          Paul added a comment - What's the current workaround for this? I need to be able to inject env vars from a file in my pipeline script, whther its with this plugin or something else?

          Jesse Glick added a comment -

          This should be closed and the plugin deprecated. There is nothing EnvInject offers to freestyle projects which you cannot already do in Pipeline.

          Jesse Glick added a comment - This should be closed and the plugin deprecated. There is nothing EnvInject offers to freestyle projects which you cannot already do in Pipeline.

          David Drum added a comment -

          David Drum added a comment - mr_pablo I believe https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#readproperties-read-properties-from-files-in-the-workspace-or-text may be what you're seeking.

          Jim added a comment - - edited

          The scenario I have, which may be similar to others, is to define a variable in the job configuration without causing side effects, such as prompting the user who triggers the build. I have automation in place to create build jobs, and I want the Jenkinsfile to utilize env.MY_JOB_VARIABLE as defined in the job configuration.

          One example where I need this is with pipeline configurations that specify a subdirectory in the Jenkinsfile path. Unfortunately, the Jenkinsfile itself does not execute within that subdirectory. To work around this, I need to wrap stages with `dir("$JENKINSFILE_SUBDIR")` so that files are correctly located. Hardcoding job-specific configuration in the Jenkinsfile is not suitable due to my separation of concerns.

          At present, I do not have a way to define a variable like `JENKINSFILE_SUBDIR` in the job configuration. And a reasonable scenario like having two Jenkinsfiles in one repo doesn't work.

           

          Jim added a comment - - edited The scenario I have, which may be similar to others, is to define a variable in the job configuration without causing side effects, such as prompting the user who triggers the build. I have automation in place to create build jobs, and I want the Jenkinsfile to utilize env.MY_JOB_VARIABLE as defined in the job configuration. One example where I need this is with pipeline configurations that specify a subdirectory in the Jenkinsfile path. Unfortunately, the Jenkinsfile itself does not execute within that subdirectory. To work around this, I need to wrap stages with ` dir("$JENKINSFILE_SUBDIR")` so that files are correctly located. Hardcoding job-specific configuration in the Jenkinsfile is not suitable due to my separation of concerns. At present, I do not have a way to define a variable like ` JENKINSFILE_SUBDIR ` in the job configuration. And a reasonable scenario like having two Jenkinsfiles in one repo doesn't work.  

            Unassigned Unassigned
            oleg_nenashev Oleg Nenashev
            Votes:
            22 Vote for this issue
            Watchers:
            36 Start watching this issue

              Created:
              Updated: