在Debian系统上配置Jenkins环境变量,主要有以下几种方法:
/etc/profile或/etc/environment,添加环境变量,例如export JAVA_HOME=/path/to/java,保存后运行source /etc/profile或重启系统使配置生效。这种方式设置的环境变量对整个系统有效,Jenkins服务重启后也可使用。environment块定义环境变量,如pipeline { agent any environment { MY_VAR = 'my_value' } stages { ... } },也可在script块中通过env对象动态设置,如env.MY_VAR = 'updated_value'。