Reputation: 137
I am working to setup CI for my NodeJS and Angular project. The manual process is to start the Node server first on cmd-A, and start the client (Angular) on different cmd-B. Then I launch the webdriver-manager to be able to test Angular Unit tests on cmd-C, and finally I execute the tests using protractor
.
I am not sure how to implement this process in a Jenkins job. I am assuming I may have to define 4 different jobs.
npm start
(for Node server)npm start
(for Angular code)webdriver-manager start
protractor tests.js
I am not sure if the server is launched in JobA that means the build is still running, how can I send a trigger to JobB (once JobA has successfully started the server). How do I set up these 4 jobs? What is the most optimized way in Jenkins for achieving this entire process?
>Project Root
>>server
>>>tests
>>>package.json
>>client
>>>comp1.ts
>>>comp1.spec.js
>>package.json
Note: Server side tests are available in server/tests
folder. Client side test are available in client/*.spec.js
files. Right now the goal is to run client tests, which as pre-requisite to start server, start client, start webdriver-manager plugin, and then run the tests.
Upvotes: 0
Views: 4375
Reputation: 804
You can create a pipeline of jobs based on upstream/downstram relationship. It's dificult show it here but I'll try.
In your first job JobA configuration add "trigger/call builds on other projects" and enter the name the following for "Projects to build field" as JobB.
It will does when your JobA finishes well JobB be executed automatically.
In your next job JobB configuration add "trigger/call builds on other projects" and enter the name the following for "Projects to build field" as JobC.
And your next JobC configuration add "trigger/call builds on other projects" and enter the name the following for "Projects to build field" as JobD.
Now you have a Build pipeline with all the jobs relations done. Then you can run the main job, in this case JobA and jenkins will follow the secuence and will execute all the jobs one after time following jobs sequence.
You should run all jobs task using a shell script and call it into the job adding a command line shell.
This is an example of the use the upstream/downstram relationship approach, that usually be use to build multiple projects in the same time.
You also can use Build Pipeline Plugin to visualize in a friendly manner the pipeline.
Latest Release: 1.5.4
Latest Release Date:Jul 27, 2016
Required Core: 1.619
Keep in mind that all process that you run by a job, have to keep runnig as a service or standalone process, That not mean that the jobs keep running too. In the last Job, next to the proactor test ended you can stop your npm servers or kill the process related.
Upvotes: 1