Skip to content

Commit

Permalink
Adding the option to overwrite the username with a job input option. …
Browse files Browse the repository at this point in the history
…The input option has to have the name "username".

For #2
  • Loading branch information
ltamaster committed Apr 25, 2018
1 parent 7871473 commit 6fda802
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ For further information see:
winrm-authtype="credssp"/>
```

The username can be overwritten using a job input option called "username".

## Limitations

Expand Down
6 changes: 5 additions & 1 deletion contents/winrm-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@

endpoint=transport+'://'+args.hostname+':'+port

username = args.username.strip('\'')
if "RD_OPTION_USERNAME" in os.environ:
username = os.getenv("RD_OPTION_USERNAME").strip('\'')
else:
username = args.username.strip('\'')


if(debug):
print "------------------------------------------"
Expand Down
9 changes: 7 additions & 2 deletions contents/winrm-filecopier.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,20 @@ def winrm_upload(
if "RD_CONFIG_NOSSL" in os.environ:
nossl = os.getenv("RD_CONFIG_NOSSL")

if "RD_OPTION_USERNAME" in os.environ:
username = os.getenv("RD_OPTION_USERNAME").strip('\'')
else:
username = args.username.strip('\'')

endpoint=transport+'://'+args.hostname+':'+port


if(nossl):
session = winrm.Session(endpoint, auth=(args.username, password),
session = winrm.Session(endpoint, auth=(username, password),
transport=authentication,
server_cert_validation='ignore')
else:
session = winrm.Session(endpoint, auth=(args.username, password),
session = winrm.Session(endpoint, auth=(username, password),
transport=authentication)

copy = CopyFiles(session)
Expand Down

2 comments on commit 6fda802

@mlamutt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this override in. Is there anyway to add the username for the project, so you can use the "command" section?

thanks again

@ltamaster
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mlamutt

I added the option to set the username from the project level

Luis

Please sign in to comment.