KR-Ravindra / JenkinsPipeline-Website-AWS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jenkins Pipelines on AWS

The following project demonstrates a CI pipeline on Jenkins:

Multibranch-pipeline | Jenkinsfile | index.html

FinalPipeline

The whole project is displayed here, in a set of screenshots. Note: URLs can be found in the search bar of the browser.

  1. Screenshot of the AWS console with the permissions being created.

    screenshot-01

  2. Screenshot showing the unique AWS URL of your EC2 instance.

    screenshot-02

  3. Screenshot that includes the unique AWS url (FQDN is used, not the IP).

    screenshot-03

  4. Screenshot that includes the unique AWS url, and shows the sidebar with the Blue Ocean link (FQDN is used, not the IP).

    screenshot-04

  5. Screenshot that includes the unique AWS url, and shows the GitHub project as a pipeline (FQDN is used, not the IP).

    screenshot-05

    screenshot-05b

  6. Screenshot that includes the unique AWS url, and shows "index.html" rendered.

    screenshot-06

    screenshot-06b

  7. Screenshot that includes the unique AWS url, and shows the failure when linting.

    screenshot-07

  8. Screenshot that includes the unique AWS url, and shows passing the linting stage and deploys to S3.

    screenshot-08

A website health check to our new website and our final pipeline.

screenshot-08b

Here is an abstract of using the multibranch pipelines which inturn could explain the blue/green deployement

A blue/green deployment, is similar to the canary deployment where two deployments exist and when the new version is available and passes certain conditions, it can be ‘swapped’ for the new one, and otherwise reverting to the older version. Amazon has a guide for CodePipeline that can be used as a reference: https://aws.amazon.com/quickstart/architecture/blue-green-deployment/

Multi-branch pipeline

![branches](screenshots/branches.png)

Insight into code of the other branches (say blue,green)

branchegreen brancheblue

Branch blue build fails due to the mismatch in tags used in index.html while the branch green build is successful as the error in index.html is fixed. (This is the foundation of blue/green dployement strategy).

Contents of Jenkinsfile

  pipeline {
    agent any
    stages {
        stage('Lint HTML'){
                steps {
                    sh 'tidy -q -e *.html'
                }
            }
        stage('Upload to AWS') {
            steps {
                retry(2){
                withAWS(region:'us-east-1',credentials:'aws-static'){
                    s3Upload(file:'index.html', bucket:'jenkinsproj', path:'')
                }
                }
            }
        }
        stage('Website Status'){
            steps{
                sh '''
                    status=$(curl -Is http://jenkinsproj.s3-website.us-east-1.amazonaws.com/ | head -n 1)
                    echo "$status"
                '''
            }
        }
    }
}

Contents of index.html

<!doctype html>
<html>
  <head>
    <title>Static HTML Site</title>
  </head>
  <body>
    <p>This is the first paragraph in a simple Static HTML site. There is no <strong>CSS</strong> or <strong>JavaScript</script>.</p>
  </body>
</html>

Return.

About


Languages

Language:HTML 100.0%