⬆️ ⬇️

Porridge, sir! Build a project on InterSystems Caché using Jenkins

On the one hand, M-programmers are so harsh that they write any application software themselves. And the task of assembling a project should not cause much difficulty. Indeed, what is difficult is to: make a request to the version control server, parse the answer and pull out the revision number, compare it with the revision number of the downloaded code, call the executable file and download the sources, load them into the database, compile , save the results, generate a report, fasten a web interface to this, add the ability to change settings, schedules, and so on. On the other hand, how much time are you going to spend on it?



If more than five minutes, then definitely worth paying attention to Jenkins . Does all of the above and will save you time every time you need to build a project. The article is based on the materials of the lecture from the school of innovations 2013 , but all attention is focused only on the minimum task - getting the source code, downloading and compiling in Caché, viewing the results.



The essence of what is happening on the video below:

  1. Download and install Jenkins
  2. Set up a working directory and connect to the repository
  3. We connect * .bat file and email notification
  4. We adjust work according to the schedule
  5. Run the assembly and see the results




Everything is beautiful, simple and convenient. All the specifics of working with Caché is hidden in the batch file:

  1. To manage the Caché server, the weakly documented cache.exe utility (located in the “Caché installation directory” \ Bin \) is used. Compared to cterm , it is more convenient because it allows you to use the usual Caché Object Script syntax (instead of send-wait cterm), and displays the results of the execution to the console of the current process. The last feature will allow us to view the build results from the Jenkins interface.

  2. Caché server to download the source code, you must pass the path to the source directory. But we already indicated it when setting up the project in Jenkins. Jenkins, in turn, before setting the script, sets the appropriate environment variables. Once and only once , right? Therefore, a technique is used when the script (cmd) creates a script (cos), writing in it the values ​​of the Jenkins variables.

  3. There are features in using the% symbols in the windows command file, but they are even described in the Caché documentation.


Batch file build.bat
:: '>' -      :: '>>' -    :: '@' -      ::    utf8 -     @chcp 65001 ::   ,  Jenkins @IF NOT DEFINED WORKSPACE EXIT 1 ::       ::             :: %CD% - [C]urrent [D]irectory    ::         (bat) @SET ERRFLAG=%CD%\error.flag ::  -      @DEL "%ERRFLAG%" ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::    CACHE ::    build.cos    Cache ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::  Cache       ::          Cache @ECHO SuperUser>build.cos @ECHO YourPassword>>build.cos ::    NAMESPACE @ECHO zn "USER" >>build.cos ::        ; :: %WORKSPACE% -  Jenkins @ECHO set sc=$SYSTEM.OBJ.ImportDir("%WORKSPACE%","*.xml","ck",.err,1) >>build.cos ::   ,  ,      Jenkins @ECHO if sc'=1 do $SYSTEM.OBJ.DisplayError(sc) >>build.cos ::    cos  - ,    bat @ECHO if sc'=1 set file="%ERRFLAG%" o file:("NWS") u file do $SYSTEM.OBJ.DisplayError(sc) c file >>build.cos ::   Cache @ECHO halt >>build.cos :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::    Cache      :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: C:\InterSystems\Cache\bin\cache.exe -s C:\InterSystems\Cache\mgr -U %%SYS <%CD%\build.cos ::     cos   -  -    Jenkins @IF EXIST "%ERRFLAG%" EXIT 1 


You can use plugins to connect to other types of storage.


')

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



All Articles