Jenkins timeout due to long running script

I have some questions regarding Jenkins and running Powershell Script inside. Long Story short: Script executes 8x longe runtime, and then launches it manually (takes only a few minutes) on the server (slave). I wonder why?

Script has functions that invoke commands like and msbuild.exe and / svn commit. I found out that Script hangs in the lines where the commanded commands are executed. As a result, Jenkins time out because Script takes so long. I can change the timeout threshold in setting up a Jenkins job, but I don’t think this is a solution to the problem. There are no errors in the conclusions or any information why it took so long, and I have no other idea for this reason. Maybe one of you could tell me how Jenkins internally calls these commands.

This is what Jenkins (plugin for Windows) does:

powershell -File %WORKSPACE%\ScriptHead\DeployOrRelease.ps1 
+6
source share
2 answers

I created my own Powershell CI Service before I discovered that Jenkins supports it; it belongs to such a plugin . But in my implementation and in my current configurations of work, we follow the principle of the principle of separation of segregation: better is better. I found that my CI service works better when split up at different stages (also in case of an error it is very easy to analyze the root causes). The principle of single responsibility is also useful here. So, as in Jenkins, we perform the preliminary, post-prefab and mail steps as a separate script. ABOUT

Msbuild.exe

As far as I remember, in my case there were problems associated with operations in FileSystem paths. Therefore, when the script was split / split in different functions, we had better performance (additional parameter checks).

0
source

Use the divide and conquer method. You have two options: change your script so that it displays what it does and how much is needed for each step. The second option is to make fewer scripts to perform actions such as:

  • get the source code
  • compile / create an application,
  • run the test
  • create a package
  • send package
  • archive magazines
  • send a notification.

The most problematic is usually the first step: get the source code from GIT or SVN or Mercurial, or something else that you have as a version control system. Make sure this step is not included in your script.

During the job, Jenkins captures the output and uses AJAX to display the result in your browser. In the script, make sure you follow the standard output for each step or several steps. Some languages ​​cache standard output so that you can only see results at the end.

You can also create log files that can be useful for archiving and checking activity status for older runs. From my experience of using Jenkins with more than 10 steps, you need to create a specialized application that can carry out several stages, such as a "robot infrastructure".

0
source

Source: https://habr.com/ru/post/956138/


All Articles