Search code examples
excelauthenticationjenkinsservice

Cannot open excel through Jenkins


I would like to use Jenkins to open an excel file (.xlsx) through bat or powershell plugin. The powershell code is very simple as shown below. And it works when I type it into the powershell. However, when I use this code in Jenkins, it will show me "successful", but actually there is no excel opened.

$excel = New-Object -comobject Excel.Application
$FilePath = 'C:\Users\igxl\Desktop\trial.xlsx'
$workbook = $excel.Workbooks.Open($FilePath)
$excel.Visible = $true

Jenkins powershell code and Console Output Jenkins powershell setup console output

I check my task manager, found there is an excel process. Although the user is igxl which is the same as my windows login account, I still need to click the 'Show processes from all users' to show it. task manager

Any advice will be appreciated.

Best regards

  1. change the logon account of Jenkins to the same as the windows login account.
  2. modify the microsoft-excel-application's identity in DCOM config to the same as the windows login account.

Solution

  • figure out what is the issue. Jenkins was installed as a service. So it was session0. And I was login as session1. There is an isolation btw session0 and session1. That's the reason why I need to press show processes from all users to see the excel.exe process.

    So there are two ways to solve this issue.

    1. break the isolation
    2. run Jenkins in session1 instead of session0

    I choose the 2nd one. Install Jenkins through the .war. Issue solved.