18 lines
1.8 KiB
Markdown
18 lines
1.8 KiB
Markdown
# Pipeline and Jenkins description
|
|
A DevOps pipeline is a set of automated processes and tools that allows developers and operations professionals to collaborate on building and deploying code to a production environment.
|
|
|
|
What does this really mean to you? It means that you should follow _**all the rules**_ when writing code and not forget to _**write tests**_, even if for some reason you didn't do it at the beginning. So, pipeline is the kind of thing that makes our lives easier. When you push your code to the repo, at first, it automatically _**runs tests**_ on the server. They may succeed or fail-it - doesn't matter: it's _**your branch**_, and your _**code won't be deployed**_ now anyway, so you will not damage anything. But when your branch is merged into `develop` and the tests are passed, it will _**automatically start deploying**_ it to the server (development or staging). There are different stages, and if one of them _**fails**_, the whole pipeline will fail and _**nothing will be deployed**_. No, in this case you won't screw everything up, the _**last successful version**_ will still be deployed and running.
|
|
|
|
Here are the stages:
|
|
|
|
1. build an app (`npm build`)
|
|
2. run tests (`npm run tests`)
|
|
3. build docker (`docker build .`)
|
|
4. push image (`docker push ${env.HOST}:${env.PORT}/comfortech/${env.IMAGE_NAME}_develop:v${BUILD_NUMBER}`)
|
|
5. clean up docker (`docker system prune --force`)
|
|
6. clean up (`cleanWs()`)
|
|
|
|
The language may vary with different commands for building apps and running tests, but the theory is general. Do not forget to add `Jenkinsfile` to your project to make the pipeline work. You can take the Jenkisfile example from our _**boilerplate**_.
|
|
|
|
When you send your code to the pipeline, you can watch it inside Jenkins. You can also restart the pipeline yourself.
|