To create the pipeline for bitbucket, we need two files i.e deploy.sh(can create for staging and production) and bitbucket.pipeline.yml in our application.
Make a directory called deployment and create the sub directory for stage and production and added the file deploy.sh inside the sub directory in our application as below:
To create the bitbucket.pipeline.yml , the file is provided by the bitbucket just we need to commit that file from the bitbucket and we can add required process to deploy through the pipeline.
First, we need to create the private key from the local using the command ssh-keygen in your terminal and that will create the public key(id_rsa.pub) and private key(id_rsa).
After creating the private key we can go the local file manager and go to Local Disk C and users and admin then .ssh directory and you will find the key we generated which shows like this:
1. After that copy the private key(id\_rsa) and go to the bitbucket 2. Go to the Repository settings and click the Repository variables then you will see the input field for key name and value, then add SSH\_PRIVATE\_KEY as a name and paste the copied private key in the value. 3.
4. Now, Enter in the server and go to vim ~/.ssh/authorized\_keys and paste the public key from id\_rsa.pub.Now the pipeline and server are ready to interact.
After adding the private key in the bitbucket and server, we need to add the fingerprint in the bitbucket for the server.To do that
Go to the Repository settings and click the SSH keys.
You will see the known hosts with the input field i.e host address and the button called fetch
Add the ip of the server in the host address and click fetch.