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

EnvInject Properties are lost when 'properties' is used in a pipeline step

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Duplicate
    • Component/s: envinject-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.32.1 LTS, EnvInject 1.93.1
    • Similar Issues:

      Description

      When using envinject in a pipeline it works, unless you add a `properties` step to your pipeline script. 

      In that case the envinject properties (along with all other properties are being removed). This goes along with such a warning in the build logs:

      ...
      [Pipeline] properties
      WARNING: The properties step will remove all JobPropertys currently configured in this job, either from the UI or from an earlier properties step.
      This includes configuration for discarding old builds, parameters, concurrent builds and build triggers.
      WARNING: Removing existing job property '[Environment Inject] -Setup a build environment'
      WARNING: Removing existing job property 'Build triggers'
      [Pipeline] node
      ...

       

      Not sure if this is an issue that can be solved on the envinject side, but it's definitively an incompatibility and I don't have a workaround yet...

       

        Attachments

          Issue Links

            Activity

            Show
            tknerr Torben Knerr added a comment - see also: https://issues.jenkins-ci.org/browse/JENKINS-41146?focusedCommentId=284719&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-284719
            Hide
            tknerr Torben Knerr added a comment - - edited

            My current workaround is to use the Jenkins API directly to add / replace a property, rather than using the `properties` step from the pipeline DSL, e.g.:

            // NOTE: it might be tempting to use the `properties` pipeline step to configure
            // the pipeline triggers. However, this removes all existing job properties (e.g.
            // the EnvInjectJobProperty as well) and may result in undesired behaviour:
            // https://issues.jenkins-ci.org/browse/JENKINS-45053
            def currentJob = Jenkins.instance.getItem(currentBuild.projectName)
            def upstreamTriggers = [ 
              new jenkins.triggers.ReverseBuildTrigger(jobs_as_string, trigger)
            ]
            currentJob.removeProperty(PipelineTriggersJobProperty.class)
            currentJob.addProperty(new PipelineTriggersJobProperty(upstreamTriggers))
            Show
            tknerr Torben Knerr added a comment - - edited My current workaround is to use the Jenkins API directly to add / replace a property, rather than using the `properties` step from the pipeline DSL, e.g.: // NOTE: it might be tempting to use the `properties` pipeline step to configure // the pipeline triggers. However, this removes all existing job properties (e.g. // the EnvInjectJobProperty as well) and may result in undesired behaviour: // https://issues.jenkins-ci.org/browse/JENKINS-45053 def currentJob = Jenkins.instance.getItem(currentBuild.projectName) def upstreamTriggers = [ new jenkins.triggers.ReverseBuildTrigger(jobs_as_string, trigger) ] currentJob.removeProperty(PipelineTriggersJobProperty.class) currentJob.addProperty( new PipelineTriggersJobProperty(upstreamTriggers))

              People

              • Assignee:
                oleg_nenashev Oleg Nenashev
                Reporter:
                tknerr Torben Knerr
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: