Issue
I am trying to write jenkinsfile from my javascript app. would it possible to parse jenkinsfile so that I can add changes to the existing jenkinsfile. Or is it possible to create a new with any npm package or third party tool?
Solution
Since you only want to reuse the same pipeline for multiple projects, I would recommend you make the repository a parameter of your pipeline.
If you want to start it manually you can set a different default value for each job.
If you want to start it via a webhook (e.g. from github) there is usually some information (including repository url, branch information and so on) included in the payload of the trigger. Personally I use the Generic Webhook Trigger Plugin with JsonPaths for this, but you might also find the github plugin more useful.
Just keep the Jenkinsfile in one central place.
Alternatively you could use commandline tools like sed to replace a placeholder in a generic pipeline (something like %REPO_URL%) or write your own little replaceStringInFile function in node (but I am sure there must be something like this out there already). But I wouldn't recommend this approach since it leads to code duplication and different versions all over the place.
Answered By - smelm