Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dinghy-lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ pub struct SshDeviceConfiguration {
pub remote_shell_vars: collections::HashMap<String, String>,
pub install_adhoc_rsync_local_path: Option<String>,
pub use_legacy_scp_protocol_for_adhoc_rsync_copy: Option<bool>,
/// Shell commands run on the device, in order, immediately before the runnable, in the
/// same remote shell invocation. A failing command does not abort the runnable or affect
/// the reported exit status.
#[serde(default)]
pub pre_run_commands: Vec<String>,
/// Shell commands run on the device, in order, immediately after the runnable exits, in
/// the same remote shell invocation. Runs even if the runnable fails; does not affect the
/// reported exit status, which is always the runnable's own.
#[serde(default)]
pub post_run_commands: Vec<String>,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
Expand Down
12 changes: 9 additions & 3 deletions dinghy-lib/src/ssh/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,20 @@ impl Device for SshDevice {
log::info!("Install {:?}", build.runnable.id);
let (build_bundle, remote_bundle) = self.install_app(&project, &build)?;
log::debug!("Installed {:?}", build.runnable.id);
let command = format!(
"cd '{}' ; {} DINGHY=1 LD_LIBRARY_PATH=\"{}:$LD_LIBRARY_PATH\" {} {}",
path_to_str(&remote_bundle.bundle_dir)?,
let run = format!(
"{} DINGHY=1 LD_LIBRARY_PATH=\"{}:$LD_LIBRARY_PATH\" {} {}",
envs.join(" "),
path_to_str(&remote_bundle.lib_dir)?,
path_to_str(&remote_bundle.bundle_exe)?,
args.join(" ")
);
let mut parts = vec![format!("cd '{}'", path_to_str(&remote_bundle.bundle_dir)?)];
parts.extend(self.conf.pre_run_commands.iter().cloned());
parts.push(run);
parts.push("RC=$?".to_string());
parts.extend(self.conf.post_run_commands.iter().cloned());
parts.push("exit $RC".to_string());
let command = parts.join(" ; ");
log::trace!("Ssh command: {}", command);
log::info!("Run {} on {}", build.runnable.id, self.id,);
if get_current_verbosity() < 1 {
Expand Down