diff --git a/src/laminar.cpp b/src/laminar.cpp
index 0860afe..d22f17b 100644
--- a/src/laminar.cpp
+++ b/src/laminar.cpp
@@ -460,6 +460,14 @@ void Laminar::assignNewJobs() {
if(fs::exists(cfgDir/"after"))
run->addScript((cfgDir/"after").string());
+ // add environment files
+ if(fs::exists(cfgDir/"env"))
+ run->addEnv((cfgDir/"env").string());
+ if(fs::exists(cfgDir/"nodes"/node.name/"env"))
+ run->addEnv((cfgDir/"nodes"/node.name/"env").string());
+ if(fs::exists(cfgDir/"jobs"/run->name/"env"))
+ run->addEnv((cfgDir/"jobs"/run->name/"env").string());
+
KJ_LOG(INFO, "Queued job to node", run->name, run->build, node.name);
// notify clients
diff --git a/src/run.cpp b/src/run.cpp
index 0a3cc71..1b27aed 100644
--- a/src/run.cpp
+++ b/src/run.cpp
@@ -17,7 +17,7 @@
/// along with Laminar. If not, see
///
#include "run.h"
-
+#include "conf.h"
#include
#include
@@ -26,7 +26,6 @@
#include
namespace fs = boost::filesystem;
-
std::string to_string(const RunState& rs) {
switch(rs) {
case RunState::PENDING: return "pending";
@@ -47,8 +46,8 @@ Run::Run() {
Run::~Run() {
KJ_DBG("Run destroyed");
- //delete log;
}
+
std::string Run::reason() const {
if(!parentName.empty()) {
return std::string("Triggered by upstream ") + parentName + " #" + std::to_string(parentBuild);
@@ -81,6 +80,13 @@ bool Run::step() {
chdir(wd.c_str());
+ for(std::string file : env) {
+ StringMap vars = parseConfFile(file.c_str());
+ for(auto& it : vars) {
+ setenv(it.first.c_str(), it.second.c_str(), true);
+ }
+ }
+
setenv("PATH", PATH.c_str(), true);
setenv("lBuildNum", buildNum.c_str(), true);
setenv("lJobName", name.c_str(), true);
@@ -110,6 +116,9 @@ bool Run::step() {
void Run::addScript(std::string script) {
scripts.push(script);
}
+void Run::addEnv(std::string path) {
+ env.push_back(path);
+}
void Run::reaped(int status) {
procStatus = status;
}
diff --git a/src/run.h b/src/run.h
index f1334ea..0e20d92 100644
--- a/src/run.h
+++ b/src/run.h
@@ -21,6 +21,7 @@
#include
#include
+#include
#include
#include
#include
@@ -57,6 +58,9 @@ public:
// adds a script to the queue of scripts to be executed by this run
void addScript(std::string script);
+ // adds an environment file that will be sourced before this run
+ void addEnv(std::string path);
+
// called when a process owned by this run has been reaped. The status
// may be used to set the run's job status
void reaped(int status);
@@ -85,6 +89,7 @@ public:
private:
std::queue scripts;
std::string currentScript;
+ std::list env;
};