Jenkins is a expansible and open source solution used to automate various process of software development like continuous integaration and continuous deployment. Interaction with the team members and remote job monitoring is most important for solid code is extensive. Jenkins give the solution for all this requirements with plugins, pipelines and environment variables.
Jenkins using Environment variables to avoid to code same values for each project. Its also provides better security. These are global value pairs. Jenkins approach environment variables and inject into a project when needed.
Let us know the steps to set the environment variable in Jenkins.
1. Set the Environment variable via Global properties:
We are able to set environment variables by navigating to "Manage Jenkins -> Configure System -> Global properties option.
First select the "Environment variables" checkbox and then add the variables and their values respectively inside the "List of Variables" section.
2. Jenkinsfile:
To create our Jenkinsfile in the environment directive to set and declare the environemnt variables globally.
Lets see how to set the variables
pipeline {
agent {
label '!windows'
}
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
echo "Database engine is ${DB_ENGINE}"
echo "DISABLE_AUTH is ${DISABLE_AUTH}"
sh 'printenv'
}
}
}
}
Comments (0)