locked
Windows Credential Dialog RRS feed

  • Question

  • I have the following requirement - in the aftermath of a Jenkins build using a post-build script plugin (which executes generic scripts) to create a ticket for a build failure in JIRA. I use the JiraPS powershell module which wraps the JIRA REST API.

    The function is New-JiraSession which takes a PSCredential Oject as argument.....so I wrap the ps exe with a very simple .cmd since PS cannot be called directly through the Jenkins plugin.....the cmd is very simple

    @echo off & setlocal
    set runPath=%~dp0
    powershell.exe -noexit -file %runPath%/TicketErstellung.ps1"

    and the corresponding part of the PS script is also simple....

    $username = "xyz"
    $pwd = Get-Content C:\TEMP\cred.txt | ConvertTo-SecureString
    $jiraCredentialObject = New-Object System.Management.Automation.PSCredential($username,$pwd)
    New-JiraSession -Credential $jiraCredentialObject

    ...this all works fine when tested directly in ISE or PS Terminal, meaning runs in automated fashion through,  however when called out of Jenkins adamantly pops the Windows Credential Dialog with the need for user input

    The corresponding log in Jenkins shows the following:

    Windows PowerShell 
    Copyright (C) 2015 Microsoft Corporation. All rights reserved.
    
    [Test2] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\SEAR\AppData\Local\Temp\hudson5839346934756539746.ps1'"
    
    Username WebSession                                     
    -------- ----------                                     
    SeanR    Microsoft.PowerShell.Commands.WebRequestSession

    ..and so clearly the session with user name is created (it copies the script into a Temp directory in the Jenkins Env for execution.

    Finally my understanding to now was not to use an interactive function like Get-Credential and so I build my own CredentialObject with New-Object.....What am I missing out and any suggestions how to suppress the unneeded dialog box.

    The dialog box appears without user name although this is hard coded in the $username variable - a technical user explicitly for this purpose and so need not be retrieved from AD or elsewhere, the fact that it runs in a PS Terminal suggest the problem may be outside PS - what causes the Dialog to pop and is there a means to suppress the interaction? I will investigate other avenues but must avoid any indication of user/pw in plain text in logs...

    Best regards




    • Edited by sean_roe Friday, June 8, 2018 12:35 PM
    Friday, June 8, 2018 11:36 AM

All replies

  • Post "Jenkins" issues in the Jenkins forum.  This is a PowerShell scripting forum.


    \_(ツ)_/

    Friday, June 8, 2018 3:45 PM