Day18 1
Day18 1
Day18 1
PIPELINE
Implementing CI-CD from the level of code.
This code is created using groovy script, and this file is also called as jenkins file.
Advantges
As pipeline is implemented as code, it gives the developers the ability to upload into vesion controlling system from
where they can edit and review the script.
Pipelines can accept interactive human input before continuning with specific stage in CI-CD
Ex: Before deployment into production environment, pipeline script can accept approval
from the delivery head and then continue.
Pipeline script support complex realtime scenario where we can implement conditional statements, loops etc.
++++++++++++++++++
Ex:
Generate piplescript -- copy the groovy code and paste in pipeline tab.
In pipeline syntax
In pipeline syntax
++++++++++++++++++++++++++++++++++++++++++
2nd stage
We need to run 'mvn package' command.
This command can be executed as a shell
script
In pipeline syntax:
Generate piplescript -- copy the groovy code and paste in pipeline tab.
++++++++++++++++++++++++++++
Step 3: Deployment
We need to establish password less SSH connection between Dev server and QA Server
Connect to QA server using gitbash
15) Connect to dev server using gitbash and generate ssh keys
$ ssh-keygen
Overwrite ? n
++++++++++++++++++++++++++
Deployment is nothing but , copying the war file from dev server to qa server
Get the location of war file from log
Script
Shell script -- copy the scp command which we have created
Deployment fails
Observe the log file ( permissions denied )
+++++++++++++++++++++++++++++++++
4th Stage: Continuous testing
In pipeline -- add a new stage
+++++++++++++++++++++++++++++++++++
5th Stage : continuous delivery
Copy the code in the - continuousdeployment and change the qa_ipaddress to prod_Ip_address
Also change the context path - prodenv
( We need to establish password less ssh between devserver and
prodserver) ( we should change tomcat8 permissions )
Go to insert mode
15) Connect to dev server using gitbash and generate ssh keys
$ ssh-keygen
Overwrite ? n
http://13.126.45.247:8080/prodenv/
+++++++++++++++++++++++++++++++++++++++++++++
Script
node('built-in')
stage('Continuous Download')
git 'https://github.com/sunildevops77/maven.git'
stage('Continuous build')
stage('Continuous Deployment')
{
sh label: '', script: 'echo "Testing Passed"'
}
stage('Continuous Delivery')
{
sh label: '', script: 'scp /home/ubuntu/.jenkins/workspace/ScriptedPipeline/webapp/target/webapp.war ubuntu@172
.31.28.16:/var/lib/tomcat8/webapps/prodenv.war'
}
}
+++++++++++++++
13.126.48.87:8080/qaenv
13.127.24.219:8080/prodenv