Showing posts with label github. Show all posts
Showing posts with label github. Show all posts

Wednesday, 30 September 2020

AWS code pipeline with S3 and Github connection

 AWS code pipeline

is a fully managed continuous delivery service that helps you to automate your release pipelines for fast and reliable application and infrastructure updates.
Automates the build,test and deploy phases of release process every time there is a change in code based on release model you defined.
This enables you to every time you deliver features and updates of app.
We can easily integrate AWS services such as GitHub or with your custom plugin.

First Host a static website on AWS S3.

Create a bucket with name 
Click on "Properties" tab after selecting on Bucket.

Click on static website hosting



Make a note of End point and click "Save".
Edit the block public access and enable public access , so that you can access this bucket outside.



Click "Save"

Click "confirm".

Add a bucket policy that your content in the bucket will be publicly available
Bucket policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::mywebsite3009/*"
            ]
        }
    ]
}

Click "save"

you can ignore the following warning message if you would like to give access to the public.

Create "entry.html" with following content and upload the same to the created bucket.

entry.html:
<html>
<head>
    <title>My static Website Home Page</title>
</head>
<body>
  <h1>Welcome to my sample website</h1>
  <p>Am hosted on Amazon S3!</p>
</body>
</html>

Upload to the S3 bucket

Now you can copy the endpoint and paste it in the browser.

In my case the below is the figure .




We have now successfully hosted static website on S3.

Now we can select "codepipeline" under AWS services

 


Enter the pipeline name and accept the default values as below and select "Next".

Select "Github" as a source and click on "connect github"

Give your Github account name and select the repository name.

click on "install" then select "connect".


Then select "Next"

For now you can skip build stage.

Under "Deploy" select below values.



Select "Next" and review the details and select "create pipeline"

Now we have created successfully created pipeline.



Change something in "my-app" source code and check the git status.



and push the changes to github.


In another way 

you can have same website files which are uploaded to S3 and github will be same.
So that when you change the code of your website , it automatically reflect the change when you push.

Since have my Java project connected with S3 via pipeline, when you push the changes of your updated java file to github. the updated file will be shown under S3.



Now you can open sample.java , it will be shown as we have updated as below

Sample.java:
public class sample {

public static void main(String args[]){
System.out.println("Thiis is my app which is created in pipeline");
}

}

This is how codepipeline will work with static website, java project and github changes.





Thank you for reading.

Tuesday, 21 July 2020

Jenkins with Github

Jenkins with Github

In previous topic, we have learned how to setup Jenkins on EC2.

Now lets see how we integrate Jenkins with Github.

Usually Jenkins comes with default plugins which will be used up to some extent.

So,here lets integrate Gihub third party plugin for continuous Integration, Basically Github is used to update , merge and get the latest code from repository among the developers.It means multiple developers will work on the same project and merge the changes continuously without issue.

So, Jenkins should have this Github plugin to pull the code from Github repository, Which has the latest code where all the developers merged once after testing of the code.

We no need to install this GitHub plugin , if you already installed git in your Jenkins.So, Lets install Git Plugin.

Lets see how to install Git plugin


  • On Jenkins Home Page , Click on Manage Jenkins

 

  • Select manage Plugins





  • Select on "Available" Tab,Filter with "GIT",




  1. Select checkbox beside Git Plugin: This will install the Git plugin
  2. Select "Install without restart": Once after install of Git , Machine doesn't restart
  3. Download Now and Install aftrer restart: Once after install Git, Machine will restart
  4. Once installation done , you can see the below screen under "installed" tab.



Now Integrate Github plugin with Jenkins job.
Configure a Jenkins Job, For this Click on
New Item-->Enter Item Name (This is jenkins job name)--> Select Freestyle Project -->OK
 

This will redirect to the below page , where you should enter project details like below.


Have my sample Github project , which have entered here and click save.

Once above step done Goto Jenkins dashboard to see the configured jobs.



Now select "Sample Job" click on build now.



You can see the job progress in the Build History.



Once its done successfully, It will show as above else , it will show as "Red" color.

You can click on #1 and select "Console output" to see the logs of the Jenkins Job




Now Your Jenkins Job is integrated with Github Project.

Also If you have Git Project , select Git option as below


Enter Project details and click on save .
Run the jenkins job once you configured to see the Job status.

"Here we configured Github Project and Git project configuring in Jenkins with in EC2 instance".