0
votes

thanks for taking time reading my issue.

I have a jenkins job that executes a shell script on a remote machine via ssh.

This script asks for username and password in a "form" way, so the two vars can not be sent as parameters. This script also verifies if the username and password are set as environment variables on the remote machine, if so, it runs without asking for inputs.

Here is the command i give to jenkins job build:

ssh [email protected] 'SVN_USER=foo SVN_PASSWORD=bar sh /app/script.sh'

--> The script runs properly BUT, it shows my credentials on the jenkins job conf and console output.

--> Now i think about parametrizing the job so that it will dynamicly ask for username/password, but i don't know how to inject them into my command line so that i can transfer them as env vars on the remote machine.

when i do:

ssh [email protected] 'SVN_USER=$LOGIN SVN_PASSWORD=$PWD sh /app/script.sh'

it doesnt consider that $LOGIN and $PWD are jenkins input vars because of the simple quotes used to execute the script.

I hope i clarified well the situation, thanks for reading !

1

1 Answers

1
votes

A good starting point for this would be Injecting-Secrets-into-Jenkins-Build-Jobs

OR

You can also use Jenkin's Environment Injector Plugin. But be sure to review the security notices while using this plugin.