So you want to run CI or even CD of your node.js project using Jenkins. Even though Jenkins interface is good enough to handle everything you need and Jenkinsfile syntax is easy to understand you may need default template to start with. So here it will be. You can use, update and do whatever you want with it until you do it for good :).
First, make sure you have Jenkins 2.x or later. Then you would need Pipline plugin - it may be already installed, check it first.
If you haven't created pipelines in Jenkins you could start from official docs. After you configure pipeline for the project you should copy sample Jenkinsfile into to the project root. Note: my Jenkinsfile uses nodeenv for isolated node.js environment creation.
So what it actually does:
- If you don't know what
agentmeans - stick with
anyvalue. (or you can read Jenkins docs)
- Environment variables are created to store values that will be used later
- Then we define stages (that will be shown separately in the Jenkins interface)
- Each stage can have title e.g.
Pre-cleanupand have several actions in it.
- After all the steps are passed we can do stuff on failure and success in the corresponding parts.
So if you want to notify your chat with the build status -
post is a good place to do it. Actually, you can check the branch and auto deploy it to the proper server if the build is successful.
Hope it'll help you.