jenkins-plugin-cli --plugins envinject:2.908.v66a_774b_31d93
envinject-plugin
This plugin makes it possible to setup a custom environment for your jobs
What is Environment Injector Plugin?
This plugin eliminates inherited environment variables from the Jenkins Java process. It injects environment variables during node (controller/agent) startup and offers flexibility by executing setup scripts before and/or after SCM checkout for a run. Additionally, it allows injection of environment variables as build steps and ensures secure handling of password values. At the conclusion of each build, it automatically exports environment variables, offering visibility into the utilized environment variables for every build.
Use Cases for Environment Injector Plugin
Use Cases
The Environment Injector Plugin offers versatile use cases to streamline environment configuration in Jenkins jobs:
-
Removing Inherited Environment Variables:
- Remove default environment variables (e.g.,
PATH
,ANT_HOME
) at the node level (controller/agent) for a job run.
- Remove default environment variables (e.g.,
-
Variable Injection:
- Inject variables in the initial step of the job, before the SCM checkout.
- Inject variables dynamically based on user parameter values.
-
Script Execution:
- Execute an initialization script before or after an SCM checkout.
-
Build Step Integration:
- Inject variables as a build step, sourced from a file populated by a preceding build step.
-
Environment Visibility:
- Access a log of environment variables utilized for each build.
-
Build Cause Integration:
- Inject build cause as an environment variable for a build.
-
Scripted Configuration:
- Dynamically inject environment variables from the evaluation of a Groovy script, powered by the Script Security Plugin.
-
Metadata Export:
- Export environment variables as metadata in your binary repository for comprehensive build documentation.
How to Use Environment Injector Plugin in Jenkins?
Job Level Configuration
Setting Up a Clean Environment:
At the job level, users can configure a clean environment for their Jenkins jobs. This ensures a pristine workspace for each job run, devoid of any residual artifacts or dependencies from previous builds. A clean environment promotes consistency and reproducibility in the build process, minimizing the risk of conflicts or unexpected behavior arising from lingering state.
To achieve this, users can leverage the Environment Injector Plugin to remove inherited environment variables and inject custom variables tailored to the specific requirements of the job. By establishing a clean environment at the outset of each job run, teams can maintain a standardized and reliable build environment, facilitating seamless integration and deployment workflows.
Injecting Variables after SCM Checkout
In Jenkins job configurations, users can inject variables after performing an SCM (Source Code Management) checkout. This feature provided by the Environment Injector Plugin allows for dynamic configuration of the build environment based on the state of the checked-out source code.
Injecting Variables as a Build Step
The Environment Injector Plugin in Jenkins empowers users to inject variables seamlessly as a build step within their job configurations. This functionality facilitates the dynamic manipulation of the build environment, allowing users to set up custom variables, define parameters, or execute scripts as part of the build process.
Monitoring GitHub Actions Workflows
CICube is a GitHub Actions monitoring tool that provides you with detailed insights into your workflows to further optimize your CI/CD pipeline. With CICube, you will be able to track your workflow runs, understand where the bottlenecks are, and tease out the best from your build times. Go to cicube.io now and create a free account to better optimize your GitHub Actions workflows!