-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Modified CI/CD workflow in the Jenkins pipeline script. * Integrated Jenkins pipeline with Docker and Ansible to execute CI/CD pipeline. * Removed Docker, Supervisor, and other configurations from the repository.
- Loading branch information
1 parent
57c4dd0
commit 7b835eb
Showing
16 changed files
with
120 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
downloads/jdk-* | ||
downloads/*.rpm | ||
downloads/*.deb | ||
downloads/*.tar.gz | ||
downloads/*.zip | ||
downloads/*.jar | ||
secret/*.pem | ||
secret/*.pub | ||
secret/node* | ||
tmp/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Kickstart Jenkins | ||
The ultimate aim of this Jenkins starter-kit is to help you run build/test of sample CRM app using Jenkins freestyle and pipeline projects. | ||
Our Jenkins starter-kit repository contains Jenkins pipeline templates and other configurations needed to implement CI/CD workflow for workloads using Jenkins. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
pipeline { | ||
agent any | ||
parameters { | ||
choice( | ||
name:'test_environment',choices:['qaa','qab'],description:'Testing environment' | ||
) | ||
} | ||
environment { | ||
TEST_ENVIRONMENT=params.test_environment.toUpperCase() | ||
} | ||
stages { | ||
stage('CI: Download sources') { | ||
steps { | ||
sh( | ||
script:'git clone https://github.com/sloopstash/kickstart-docker.git kickstart-docker', | ||
returnStatus:true | ||
) | ||
sh( | ||
script:'git clone https://github.com/sloopstash/kickstart-ansible.git kickstart-ansible', | ||
returnStatus:true | ||
) | ||
} | ||
} | ||
stage('CI: Build OCI images') { | ||
steps { | ||
dir('kickstart-docker') { | ||
sh 'sudo docker image build -t sloopstash/base:v1.1.1 -f image/base/1.1.1/amazon-linux-2.dockerfile image/base/1.1.1/context' | ||
sh 'sudo docker image build -t sloopstash/nginx:v1.14.0 -f image/nginx/1.14.0/amazon-linux-2.dockerfile image/nginx/1.14.0/context' | ||
sh 'sudo docker image build -t sloopstash/python:v2.7 -f image/python/2.7/amazon-linux-2.dockerfile image/python/2.7/context' | ||
sh 'sudo docker image build -t sloopstash/redis:v4.0.9 -f image/redis/4.0.9/amazon-linux-2.dockerfile image/redis/4.0.9/context' | ||
} | ||
} | ||
} | ||
stage('CI: Bootstrap testing environment') { | ||
steps { | ||
dir('kickstart-docker') { | ||
sh "sudo docker compose -f compose/crm.yml --env-file compose/${TEST_ENVIRONMENT}.env -p sloopstash-${params.test_environment}-crm up -d" | ||
sh "sudo docker container exec sloopstash-${params.test_environment}-crm-app-1 pip install pytest" | ||
} | ||
} | ||
} | ||
stage('CI: Execute test cases') { | ||
environment { | ||
APP_SOURCE='/opt/app/source' | ||
} | ||
steps { | ||
sh "sudo docker container exec --workdir ${APP_SOURCE} sloopstash-${params.test_environment}-crm-app-1 pytest --junitxml=reports.xml script/test/main.py" | ||
} | ||
post { | ||
// always { | ||
// junit 'reports.xml' | ||
// } | ||
success { | ||
input 'App testing has been successful. Do you want to proceed deployment in staging environment?' | ||
} | ||
} | ||
} | ||
stage('CD: Bootstrap staging environment') { | ||
steps { | ||
dir('kickstart-ansible') { | ||
sh 'sudo docker compose -f docker/compose/crm.yml --env-file docker/compose/STG.env -p sloopstash-stg-crm up -d --scale app=3 --scale nginx=2' | ||
} | ||
} | ||
} | ||
stage('CD: Execute deployment') { | ||
steps { | ||
dir('kickstart-ansible') { | ||
ansiblePlaybook( | ||
credentialsId:'ansible-node-ssh', | ||
playbook:'playbook/redis.yml', | ||
inventory:'inventory/stg', | ||
tags:'setup,configure,stop,start' | ||
) | ||
ansiblePlaybook( | ||
credentialsId:'ansible-node-ssh', | ||
playbook:'playbook/crm/app.yml', | ||
inventory:'inventory/stg', | ||
tags:'setup,update,configure,stop,start', | ||
limit:'sloopstash-stg-crm-app-1' | ||
) | ||
ansiblePlaybook( | ||
credentialsId:'ansible-node-ssh', | ||
playbook:'playbook/nginx.yml', | ||
inventory:'inventory/stg', | ||
tags:'setup,update,configure,stop,start', | ||
limit:'sloopstash-stg-crm-nginx-1' | ||
) | ||
} | ||
} | ||
post { | ||
success { | ||
input 'Deployment has been successful. Do you want to proceed deployment in production environment?' | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
dir('kickstart-docker') { | ||
sh "sudo docker compose -f compose/crm.yml --env-file compose/${TEST_ENVIRONMENT}.env -p sloopstash-${params.test_environment}-crm down" | ||
} | ||
dir('kickstart-ansible') { | ||
sh 'sudo docker compose -f docker/compose/crm.yml --env-file docker/compose/STG.env -p sloopstash-stg-crm down' | ||
} | ||
emailext( | ||
subject:'Jenkins: ${env.JOB_NAME} - ${currentBuild.currentResult}', | ||
body:'${env.BUILD_NUMBER} ${env.JOB_NAME} execution ${currentBuild.currentResult}.\n Know more at ${env.BUILD_URL}.', | ||
recipientProviders:[[$class:'DevelopersRecipientProvider'],[$class:'RequesterRecipientProvider']] | ||
) | ||
} | ||
success { | ||
cleanWs( | ||
deleteDirs:true, | ||
disableDeferredWipeout:true | ||
) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.