Allow external access to containers running in Pipelines via a custom subdomain

Issue #14236 wontfix
Eddie Webb
created an issue

I want to use SauceLabs to test my product that runs across multiple Atlassian server products.

The Docker images have a hostname like

<baseurl>http://724babeb-d690-452c-aa9b-ef5660af34ae:5990/product</baseurl>

But that's not a URL available external to the container.

I would like to see something like

<baseurl>http://724babeb-d690-452c-aa9b-ef5660af34ae.pipelines.bitbucket.org:5990/product</baseurl>

So that external testing tools like Sauce Labs can access the running containers.

https://bitbucket.org/eddiewebb/statuspage-banner-atlassian-server/addon/pipelines/home#!/results/%7Bba811533-a428-4238-b66c-12bb6497909c%7D

Official response

  • Matt Ryall staff

    Although it's not as nice as a built-in feature, it's possible to do this today with Bitbucket Pipelines and ngrok.

    You need to sign up on their site to use a "named" subdomain, and either download or install the ngrok client in your build script or use a Docker image which includes it (which I've done below).

    Here's my example build script:

    image: ubuntu
    
    pipelines:
      branches:
        master:
          - step:
              image: fnichol/ngrok
              script:
                - ngrok authtoken $NGROK_TOKEN
                - ngrok http -subdomain mryall 12345
    

    Tweaks you'll need to make:

    • add your ngrok authentication token as a secure environment variable called NGROK_TOKEN in Bitbucket Settings
    • change mryall to whatever subdomain on ngrok.com you want to use
    • change 12345 to match the port you want to tunnel.

    I didn't hook ngrok up to anything in the example above, but could see the tunnel successfully connected by checking my ngrok dashboard.

    Note that if ngrok is running successfully, no output appears in Pipelines because it is still buffered by the container. There might be some way to prevent the shell buffering the output, but I didn't quite get up to figuring that out yet.

    Hope this helps!

Comments (6)

  1. Matt Ryall staff

    Although it's not as nice as a built-in feature, it's possible to do this today with Bitbucket Pipelines and ngrok.

    You need to sign up on their site to use a "named" subdomain, and either download or install the ngrok client in your build script or use a Docker image which includes it (which I've done below).

    Here's my example build script:

    image: ubuntu
    
    pipelines:
      branches:
        master:
          - step:
              image: fnichol/ngrok
              script:
                - ngrok authtoken $NGROK_TOKEN
                - ngrok http -subdomain mryall 12345
    

    Tweaks you'll need to make:

    • add your ngrok authentication token as a secure environment variable called NGROK_TOKEN in Bitbucket Settings
    • change mryall to whatever subdomain on ngrok.com you want to use
    • change 12345 to match the port you want to tunnel.

    I didn't hook ngrok up to anything in the example above, but could see the tunnel successfully connected by checking my ngrok dashboard.

    Note that if ngrok is running successfully, no output appears in Pipelines because it is still buffered by the container. There might be some way to prevent the shell buffering the output, but I didn't quite get up to figuring that out yet.

    Hope this helps!

  2. Matt Ryall staff

    Given the low interest in this feature, we don't have plans to build this any time soon.

    For now, the best way is using the ngrok tunnel described above.

  3. Log in to comment