Skip to content

[JENKINS-60949] [EnvInject] Injecting properties of previous build breaks SCM polling #634

Description

@jenkins-infra-bot

The EnvInject plugin re-injects the environment of the previous build into the SCM poll for the next build.

However, it does this blindly, without considering when and where the previous build happened, and without knowing if the properties are actually applicable.

Scenario:

  1. Have 2 slaves (slave-linux, slave-windows)
  2. Configure job for SCM polling
  3. Build job for the first time -> runs on slave-linux
  4. builds/1/injectedEnvVars.txt contains, for example, HOME=/home/jenkins
  5. Wait for next SCM poll.
  6. SCM poll runs on slave-windows this time.
  7. EnvInject blindly takes the env vars from injectedEnvVars.txt from build 1 and injects it into the SCM polling process.
  8. SCM polling on Windows fails, e.g. with "Could not create directory '/home/jenkins/.ssh'." because of the wrong HOME environment variable.

Is there a way to prevent this? The job in question does not even make use of the EnvInject functionality, yet, injecting still happens at SCM polling time.


Originally reported by sratz, imported from: [EnvInject] Injecting properties of previous build breaks SCM polling
  • status: Open
  • priority: Major
  • component(s): envinject-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 2
  • imported: 20251223-165436
Raw content of original issue

The EnvInject plugin re-injects the environment of the previous build into the SCM poll for the next build.

However, it does this blindly, without considering when and where the previous build happened, and without knowing if the properties are actually applicable.

Scenario:

  1. Have 2 slaves (slave-linux, slave-windows)
  2. Configure job for SCM polling
  3. Build job for the first time -> runs on slave-linux
  4. builds/1/injectedEnvVars.txt contains, for example, HOME=/home/jenkins
  5. Wait for next SCM poll.
  6. SCM poll runs on slave-windows this time.
  7. EnvInject blindly takes the env vars from injectedEnvVars.txt from build 1 and injects it into the SCM polling process.
  8. SCM polling on Windows fails, e.g. with "Could not create directory '/home/jenkins/.ssh'." because of the wrong HOME environment variable.

Is there a way to prevent this? The job in question does not even make use of the EnvInject functionality, yet, injecting still happens at SCM polling time.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions