Jenkins won't execute correctly a command from a .bat - html

I have set up Jenkins so that it builds my project, runs some tests and then creates an HTML page containing a report.
I made a .bat file to open the html report in my browser. There is just one line in that .bat file :
"E:\user\Visual Studio 2010\JenkinsWorkspace\JobTest\index.html"
When I run that .bat in a prompt myself, the page index.html is open (so it works).
But the problem is that when I set up a Jenkins' job to run that .bat, nothing happens.
The job gets stuck after calling the .bat and never finishes.
Any idea why?
Note: I have other .bat (that do not open html pages) that are successfully executed by Jenkins.
EDIT: here is the errors I get in the prompt log from Jenkins's menu :
C:\Program Files\Jenkins\jobs\JobTest2_enUnSeulScript\workspace>echo "
Opening html page" " >> Opening html page"
C:\Program
Files\Jenkins\jobs\JobTest2_enUnSeulScript\workspace>"C:\Program
Files\Google\Chrome\Application\chrome.exe" "E:\user\Visual
Studio 2010\JenkinsWorkspace\JobTest\testResults.14h05m15s65ms.11.04.2013.trx.htm"
[688:3900:0411/140520:ERROR:gpu_info_collector_win.cc(96)] Can't
retrieve a valid WinSAT assessment.
[688:3900:0411/140520:ERROR:process_singleton_win.cc(540)] Lock file
can not be created! Error code: 32
[688:3900:0411/140520:ERROR:chrome_browser_main.cc(1157)] Failed to
create a ProcessSingleton for your profile directory. This means that
running multiple instances would start multiple browser processes
rather than opening a new window in the existing process. Aborting now
to avoid profile corruption.
Build step 'Exécuter une ligne de commande batch Windows' marked build as failure [htmlpublisher]
Archiving HTML reports... [htmlpublisher] Archiving at PROJECT level
E:\user\Visual Studio 2010\JenkinsWorkspace\JobTest to C:\Program
Files\Jenkins\jobs\JobTest2_enUnSeulScript\htmlreports\HTML_Tests_Report
Finished: FAILURE

If you are running Jenkins as a Window's service, you will probably need to enable the service to interact with the desktop. Do the following:
Open the Services module
Right-click on Jenkins and select "Properties"
On the "Log On" tab, run as "Local System account" and select the "Allow service to interact with desktop" checkbox
-- OR --
You can run Jenkins via the command-line. Ie: "java -jar jenkins.war".

I am guessing that your Jenkins install is running as a Windows Service. When Jenkins is run as a service on a Windows machine it runs under the System account, not a user account. The System account usually does not have the same settings as a user account.
You might want to try starting a CMD shell as the System Account. (The answers to this question should help you with that: How Do You Run CMD under System Account.) From there, try running the batch file and see what happens. You may find that you need to setup somethings like the PATH before it works.

I know this is late, but I just answered another question on how to open an .exe (or .bat) from Jenkins's service on Windows
Open Excel on Jenkins CI
The issue is that while your command actually works, it does that in Session 0 (which is the session of Local System user that launched your Jenkins service), which you cannot see while being logged in through your own user account, most likely in Session 1.
Hope this helps

Related

Console command for opening files inside already opened project in PhpStorm

I've faced the problem. I use PhpStorm to edit files from FTP server using WinSCP client. In WinSCP client I've set command for using external editor. So, when I try to open php-file from remote FTP server WinSCP downloads this file in temporary file and open it using command provided by me - "C:\Program Files\JetBrains\PhpStorm 2020.1.1\bin\phpstorm64.exe" "!.!"
Earlier, when I used PhpStorm 2019 or 2018, it opened file in already opened window/project. But when I've upgraded to PhpStorm 2020, it started to open file from FTP in separate windows. It's so annoying and some functionality doesn't work in such case (auto suggestions and others).
I know that I can use built-in remote files browser within PhpStorm to view and edit remote files, but I accustomed to use separate FTP client for such purposes.
Does somebody know how to fix this problem? What console command should I use so as to open separate file in already opened window/project?
It's a LightEdit mode: https://blog.jetbrains.com/idea/2020/04/lightedit-mode/
Since 2020.2 you can use the -p (--project) option instead to force opening files in already opened project windows. For example idea -p myfile.txt. IDEA-237118
You can also permanently disable that mode by following these steps:
Invoke Help | Find Action... (or via Search Anywhere: use Double Shift and switch to Actions tab)
Search for Registry... action and select it
Once in the Registry dialog locate light.edit.file.open.enabled entry (just start typing, speed search will narrow it down) and set it to false (uncheck the box).
Not sure if IDE restart is needed (probably not).

Error trying to read the VSIX manifest file... The system cannot find the file specified

I am trying to build a Visual Studio Package project via Hudson CI. This is a Visual Studio 2010 project. The project builds fine in my dev box, but for some reason, I keep getting the following error only when building in Hudson:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.targets(378,5): error : Error trying to read the VSIX manifest file "obj\Release\extension.vsixmanifest". The system cannot find the file specified. (Exception from HRESULT: 0x80070002) [C:\hudson\workspace\MyProject_Daily_Compilation\Source\MyProject.VisualStudio\MyProject.VisualStudio.csproj]
I have verified that the file exists on disk in the following location:
C:\Hudson\workspace\MyProject_Daily_Compilation\Source\MyProject.VisualStudio\obj\Release\extension.vsixmanifest
What could be causing this issue?
You are likely to experience such error if the user you are running your build as does not have administrative privileges.
So there are 2 solutions:
1) Run your build (build server) with administrative privileges.
or if you can't really change the user your build server is running on
2) and you actually don't need to deploy the VS extension on the build server itself, set the DeployExtension property in your *.csproj file to false.
Microsoft.VsSDK.targets sets that property by default to true
<DeployExtension Condition="'$(DeployExtension)' == ''">true</DeployExtension>
but if you don't need to deploy that extension locally (but rather would prefer to get the *.vsix bundle built you can safely put
<PropertyGroup>
<DeployExtension>false</DeployExtension>
</PropertyGroup>
The original error is basically happening because the attempt to get the deployment path fails at some point in the build and disrupts successful vsix package generation. By setting the property to false the build doesn't attempt to deploy the extension locally (but a valid *.vsix is generated)
I am guessing you running hudson as a service. If so the "0x80070002 - The system cannot find specified file" could well be due to the user being used to run hudson does not have access.
The quick solution to this is change the "Log on" user for the Hudson service to be your normal account.

Hudson svn credentials

How to enter subversion credentials in Hudson by shell?
I've tried to generate file hudson.scm.SubversionSCM.xml in HUDSON_HOME and reload configuration, but changes weren't applied.
The easiest way to enter a credential from the shell is to use "svn" executable. Hudson recognizes the ~/.subversion/auth directory that it creates.
Under Windows the global credenentials are stored under %APPDATA%\Subversion\auth. The following Groovy code helps generating these credentials:
SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url))
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(SVNWCUtil.defaultConfigurationDirectory,"AD\user","password",true)
repository.setAuthenticationManager(authManager)
repository.getDir("", -1, null ,(Collection)null) // or some random SVN operation
Libraries used in the code above (example in Gradle):
compile 'org.tmatesoft.svnkit:org.tmatesoft.svnkit:1.7.8'
compile 'net.java.dev.jna:jna:3.4.0' // so wincrypt is available
Make sure you run the code with the same user Hudson runs on the Windows machine.
Just start with the Hudson.
Install all required Plug-Ins.
Hit the link,EX:-localhost:8080/hudson
Click on the add job/Create job.
While choosing the options SVN will be present there,Give the SVN location.
Credentials link is present out there.Click on that link.
A form will get open,provide valid credentials for that location of SVN.
Observe the Success message on the screen and then get back to the Create job,Complete with Job creation and Build the task.

Why can't I run my Perl job in Hudson?

I tried to do this in Hudson but:
I have a script in Perl on my server (windows): lets say: d\util\demo.pl I want to have it running in Hudson. so I go to Hudson, create new job, go to: Build Execute Windows batch command and add: perl.exe d\util\demo.pl
I got this error: 'perl.exe' is not recognized as an internal or external command, operable program or batch file.
please help!
It can't find the perl.exe in the path of the agent that is running the task. Verify that perl is properly installed AND that the path where perl.exe was in stalled to is in you system path on EVERY agent that will run this task.
Can you run that command from any folder of the server?
If yes, than the Hudson server runs definitely under a different user account. Make sure that the user account Hudson is running under has all necessary environment variables set.
If not, than add the full qualified path to the perl.exe (e.g. C:\program files\perl\bin\perl.exe d:\util\demo.pl). If this doesn't help, you have to also set all environment variables (see "if yes").

SSIS package not running when called as step in SQL Job

I have a .dtsx file (an SSIS package) that downloads files from an FTP server and imports data. It runs fine whenever I run it manually. However, when I schedule calling the package as a step in a SQL server agent job, it fails. The step it fails at is the one where I call a .bat file. The error in the job history viewer says this:
Error: 2009-05-26 12:52:25.64
Code: 0xC0029151 Source: Execute
batch file Execute Process Task
Description: In Executing
"D:\xxx\import.bat" "" at "", The
process exit code was "1" while the
expected was "0". End Error DTExec:
The package execution returned
DTSER_FAILURE (1).
I think it's a permissions issue, but I'm not sure how to resolve this. The job owner is an admin user, so I've verified they have permissions to the directory where the .bat file is located. I've tried going into Services and changing the "Log On As" option for SQL Server Agent, and neither option works (Local System Account and This Account). Does anyone have ideas as to what other permissions need to be adjusted in order to get this to work?
I tried executing just the batch file as a SQL Job step, and it gave more specifics. It showed that it failed when I was trying to call an executable, which was in the same directory as my .bat file, but not in the windows/system32 directory, which is where it was executing from.
I moved the executable to the system32 directory, but then I had no clue where my files were being downloaded to. Then I found that there's a property for the Execute Process Task (the one that executes the .bat) called WorkingDirectory. I set this to be the directory where the bat is located, moved the executable back into the same one as the .bat file, and it's now working as expected.
For me it was a permissions issue. Go to Environment --> Directories, then change Local directory to something the SQLAgentUser can access. I used C:\temp. Click the dropdown for Save, and choose "Set defaults".
Are you executing the SSIS job in the batch file, or is the batch file a step in the SSIS control flow?
I'm assuming the latter for this answer. What task are you using to execute the batch file (e.g. simple execute program task or a script task). If the latter, it looks like your batch file is actually failing on some step, not the SSIS script. I'd check the permissions of what your batch file is trying to access
In fact, it might be a better idea to rewrite the batch file as a script task in SSIS, because you'll get much better error reporting (it'll tell you which step in the script fails).
You could try executing the batch file using the runas command in a command window. If you try and execute it under the local system or network system account, it should give you a better error. If it does error, you can check the error level by going "echo %ERRORLEVEL%".
If it wasn't the latter, and you're executing the SSIS package via a batch file, why?
Are you possibly accessing a mapped drive in your .bat file? If so, you can't rely on the mapped drive from within the service, so you'd have to use UNC path.
I had the same error and I resolved it by logging on to the user account that runs the job, opened Coreftp site in question there, test the site access, made the change there (in my case, I had to reenter the new password) and now it works.
So yes, it is an issue of file access. This one is file access to the coreftp site in question.