Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.
This repository was archived by the owner on May 25, 2025. It is now read-only.

Send ssh environment variables #291

@laurentmorin29

Description

@laurentmorin29

In my use case, I push some code on batch servers using gradle ssh plugin.
Recently, my SSI added the requirement of passing specific environement variables to log the reason of access.

New feature

SSH allows client to send environment variables to the target host using setEnv method on ChanelExec.
https://epaul.github.io/jsch-documentation/javadoc/com/jcraft/jsch/ChannelExec.html#setEnv-java.lang.String-java.lang.String-

Configuration

  1. add a config map(string,string) of values into the gradle config to provides all variables and maybe could be merged with definitions provided on run or session
ssh.settings {
    env {
        var_1 = 'var_1 content'
        var_2 = 'var_2 content'
   }
}

Update

As I could see, the Command.groovy script could simply merge parent env configs and use setEnv for all of them on the channel

https://github.com/int128/groovy-ssh/blob/master/core/src/main/groovy/org/hidetake/groovy/ssh/operation/Command.groovy

Sorry I'm not fluent with groovy dev so I created this issue and not a PullRequest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions