Tuesday 4 May 2021

ngrok - Time saver when you want to expose local host to internet

I was working with bitbucket pipelines and integrating with spinnaker webhooks. Since SPINNAKER does not have a direct interaction with bitbucket pipelines. I started using webhooks from spinnaker and able to trigger bitbucketpipeline from SPINNAKER by calling API end points.

    Now the real problem is I need to trigger the spinnaker pipeline from bitbucket. So Bitbucket should call the SPINNAKER API webhook end point. I setup everything in my local spinnaker and bitbucket server which is in cloud is not able to call the local end point . What I did is I setup a webhook in my bitbucket pipeline for each commit. Bitbucket trying to ping my local url and throw error like invalid uri. from few posts on Atlassian forums suggesting ngrok to expose localhost to internet (from security wise its dangerous if its not secured/ controlled) . 

    Then finally I tried ngrok and the options its providing is super cool. Its much simple to use for testing purposes. The download size also so less and the command is like 'ngrok.exe http portnumber' thats it. Its providing a simple dashboard to monitor the incoming requests (which is very good to know who is using our end points). also providing inspect functionality, status codes and able to view header and body of incoming and response . Also we can setit for time bound after that it dissolves itself. We can load the dashboard from localhost:4040

 

 


If you register for their services, they provide an account with auth token and dashboard where we can see all tunnels . Also we can override the 2 hrs limit. They also provide an API end point so that we can programmatically expose the end points and destroy them automatically after use which is super cool. 

 

Monday 3 May 2021

Powershell - CURL error Ambiguous parameters in the command

 Powershell - CURL error Ambiguous parameters in the command :


I tried to invoke bitbucket pipelines from API using CURL command. I installed CURL first in powershell using chocolatey - Choco install curl . Then opened a new window and tried by prebuilt POST request in curl .

$ curl -X POST -is -u username:password `

  -H 'Content-Type: application/json' `

 https://api.bitbucket.org/2.0/repositories/test/testdemo/pipelines/ `

  -d '

  {

    "target": {

      "ref_type": "branch",

      "type": "pipeline_ref_target",

      "ref_name": "master"

    }

  }'

First I used line separator as "\" in end of each line which is shell format which is not recognized by powershell . Later I replaced "\" with back quote "`" character. 

After entering the command , Powershell throws error like "Parameter cannot be processed because the parameter name 'u' is ambiguousPossible matches" 

Then I found that by default Powershell tried to call Invoke-Request alias instead of calling curl.exe. Stack overflow suggested to remove the alias and proceed. I removed the alias by executing the below command

Remove-item alias:curl
This did the magic and now my powershell is calling the bitbucket API to execute my pipeline.

Shrinking the size of Oracle Virtual Box

First, zero fill your virtual disk. Boot the VM and run: sudo dd if=/dev/zero of=/bigemptyfile bs=4096k status=progress sudo rm -f /bigempty...