Friday, February 2, 2018

How to create CICD pipelines or build definitions in VSTS - Create CICD Pipelines using Azure DevOps

How to configure CI/build pipeline in VSTS?
Lets us see the steps for creating CICD pipeline using VSTS or Azure DevOps.
Login to VSTS, choose project dashboard.
Go to Pipelines
Click on builds.

Click on new Build pipelines





Choose Bitbucket as a source

Click on  Change, New service connection. Click on username and password.
enter bitbucket user name and password. Click on Authorize.












Choose the repository. Click Continue.

Now choose a template by entering Java in the search textbook.

Select “Azure Web App for Java” template, Click Apply.
Now click on Agent queue, select Hosted.
Click on get sources. Select Git repo, branch as master. 
Click on Maven pom.xml task and select the maven pom.xml by clicking on three dots …make sure you change to MyWebApp/pom.xml
goal should be clean install
Leave the default value in copy files to staging folder
Leave the default value in publish artifact :drop
Click on Stop azure web app
Enter Azure subscription.

Select Free trial subscription from the drop down.
Click on authorize










Create App service on Azure portal
Now to login portal.azure.com
click on App services

Click on + Add
Click on Web App.
Create
Enter App service name(it should be unique)
Create a new resource group(for first time if you create an app service, otherwise you can use existing group name)

Select azure free subscription

Leave the rest default click save/create




Save and try to access the app service url by going to overview section of app service.

After you see the app service home page, come back to VSTS
Choose the app service name from the drop down.
Do the same thing Deploy Azure WebApp and Start Azure Web App task.
Now click on Triggers to enable Continuous integration enabled so it builds for every check-in.

Click on Save & Queue to kick start the build.

How to set up SSH keys in Azure Repos | Setup SSH keys and Java Web App in Repos in Azure DevOps

How to set up SSH keys in Azure Repos and Setup WebApp in Azure Repo


Go to your visual studio home page. You should be able to go by clicking on the below URL.
https://dev.azure.com/

Create a new project by clicking on New project and enter project details like below. This will create a project dashboard.


Once project is created, Click on Repos.


 Click on initialize link to add README.



Click on clone link on the top right hand side.
Click on SSH link
Click Manage SSH keys

Click Add

Go to any virtual machine you had setup that has both Java and Maven installed. If you would like to know how to create a Virtual Machine in Azure Cloud, click here to do so.

Create the SSH keys by executing the below command:
(If you already have keys generated, you can overwrite it or skip to next step to copy keys)
ssh-keygen

execute the below command to copy the keys:

cat ~/.ssh/id_rsa.pub

Add the public keys.
Once keys added into Azure DevOps, go to Repos, copy the SSH clone url

Go to your machine where you have installed Java, Maven, preferably your EC2. Execute this command:
git clone <ssh_url>

This should download the empty repo from Azure DevOps to local machine(or ec2).
now after cloning, it will create a folder with repo name..

type 

ls -al to see the folder name after you cloned.

go inside that folder by
cd reponame

Now create the maven project executing the below command:
mvn archetype:generate -DgroupId=com.cf -DartifactId=MyAwesomeApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

type git status --> to see the newly created project
git add *
git status

git commit -m "my first project check-in to Azure Repos"
git push

Now go to Azure DevOps, Select the Repos —> Files —> you should see the project uploaded here.



Thursday, February 1, 2018

Region does not seem to be available error for AWS module boto.ec2

When you have this error, there is a good chance that your boto version is outdated. You will have to update the boto version by executing the below command:


pip install boto


This will install latest version of Boto framework which is 2.48.0. 

you can confirm by executing the below command:
pip list boto | grep boto

boto (2.48.0)
boto3 (1.5.22)
botocore (1.8.36) 

Saturday, January 27, 2018

Git Workflow and commands | Git popular commands


git init

This command turns a directory into an empty Git repository. This is the first step in creating a repository. After running git init, adding and committing files/directories is possible.

git add

Adds files in the to the staging area for Git. Before a file is available to commit to a repository, the file needs to be added to the Git index (staging area). There are a few different ways to use git add, by adding entire directories, specific files, or all unstaged files.

git commit

Record the changes made to the files to a local repository. For easy reference, each commit has a unique ID.
It’s best practice to include a message with each commit explaining the changes made in a commit. Adding a commit message helps to find a particular change or understanding the changes.

git status

This command returns the current state of the repository.

git clone

To create a local working copy of an existing remote repository, use git clone to copy and download the repository to a computer.

git fork
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

git pull
To get the latest version of a repository run git pull. This pulls the changes from the remote repository to the local computer.

git push

Sends local commits to the remote repository. git push requires two parameters: the remote repository and the branch that the push is for.

git checkout

To start working in a different branch, use git checkout to switch branches.

git merge

Integrate branches together. git merge combines the changes from one branch to another branch. For example, merge the changes made in a staging branch into the stable branch.

git commit --amend

You can also re-write history of your most recent commit in your local git repository by using git commit --amend command.

git commit --amend

sudo: no tty present and no askpass program specified - How to fix no tty present and no askpass program specified error?

You may get this error during deployment to Tomcat from Jenkins. 
The fix for deployment to Tomcat from Jenkins is:

type --> sudo visudo
look for root and make the changes highlighted in red and save the file and re-do the deployment in Jenkins.

# User privilege specification 


root ALL=(ALL:ALL) ALL 
jenkins ALL=(ALL) NOPASSWD: ALL

Thursday, January 25, 2018

How to resize memory in EC2 instance in AWS?

Please find steps below to increase or decrease memory for the EC2 instances. For example, if your t2.micro instance is too small for its workload, you can change it to an m3.medium instance.

1. Go to AWS console, choose the instance, instance state, click on stop the instance.
2. once stopped, go to Instance settings, change Instance type to desired type
3. Start the instance again.

That's it. You don't have to create a new instance. This is how you do it!