Jenkins Declarative Pipeline
Jenkins Declarative Pipeline
LINKEDIN: https://www.linkedin.com/in/ritikktiwari/
• Go to AWS Console
• Select ubuntu Operating system
• Instances(running)
• Launch instances
We need to modify the user permission and append the ubuntu user in docker group:
Then reboot your system once and wait for few minutes.
Docker file:
FROM python:3.9
WORKDIR /app/backend
COPY . /app/backend
EXPOSE 8000
Installation of Jenkins
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
Now you need to go to your Brower and paste the public IP address of your server
eg: http://PublicI:8080/
If port is not enabled, then you need to enable that port: 3000 on your aws security group:
Steps:
Paste it on your browser: http://PublicI:8080/
This is Groovy syntax, and it’s the structure of Declarative Pipeline , Let me
show you the output of every stages.
pipeline {
agent any
stages{
stage("Code"){
steps{
stage("Build"){
steps{
}
stage("Push to Docker Hub"){
steps{
stage("Deploy"){
steps{
pipeline {
agent any
stages{
stage("Code"){
steps{
stage("Build"){
steps{
steps{
stage("Deploy"){
steps{
First go to Jenkins Dashboard > Manage Jenkins > Security: Credentials > click on system
We need to assign ID for username and password, because if anyone ask then we can give our ID no.
which contains username and password.
Now back to dashboard and come in configuration
pipeline {
agent any
stages{
stage("Code"){
steps{
stage("Build"){
steps{
steps{
withCredentials([usernamePassword(credentialsId:"dockerhub123", passwordVariable:
"dockerhubPass", usernameVariable:"dockerhubUser")]){
stage("Deploy"){
steps{
}
Now we are going to push our image on docker hub using declarative pipeline.
pipeline {
agent any
stages{
stage("Code"){
steps{
stage("Build"){
steps{
withCredentials([usernamePassword(credentialsId:"dockerhub123", passwordVariable:
"dockerhubPass", usernameVariable:"dockerhubUser")]){
stage("Deploy"){
steps{
It’s type of yml file where are the things are explained.
Container or image ko down kiya aur phir up kiya inhi code se.
If we are going to run that application with the help of docker-compose what will happen, it will throw
error,
Now run docker-compose up -d, this will decide automatically, image or container name.
This is the solution of above error. Let me add this code in groovy syntax.
Lets change the little bit docker-compose file: build replace with image, now we are taking images
from docker hub.
We have committed few things, now you can run as much as possible, never getting error.
Copy whole pipeline code, go to GitHub> add new file> paste same code as Jenkins file> commit it.
Then:
Application has been deployed successfully.
Webhook concept:
A webhook is a mechanism by which GitHub notifies Jenkins of changes to a repository.
Jenkins can then automatically build and test the code in response to the webhook
notification.
LinkedIn: https://www.linkedin.com/in/ritikktiwari/