1.8 KiB
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:
- build an app (
npm build
) - run tests (
npm run tests
) - build docker (
docker build .
) - push image (
docker push ${env.HOST}:${env.PORT}/comfortech/${env.IMAGE_NAME}_develop:v${BUILD_NUMBER}
) - clean up docker (
docker system prune --force
) - 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.