How to use the BB Pipelines Azure Deployment

Rodney Joyce December 4, 2016

Hello,

I might be missing something obvious, but I am getting started with Pipelines and want to deploy a simple project to Azure. 

According to your documentation, https://bitbucket.org/mojall/bitbucket-pipelines-deploy-to-azure is how to integrate with Azure. On this page, there is not much except a VS Code extension. 

I cloned the repo, installed the extension (I do not use VS Code) and am not sure how to proceed now... there's no instructions at all for what to do next?!

Is there any documentation on how to deploy to azure or a simple example perhaps?

Thanks

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Rodney Joyce January 23, 2017

Ok, so I finally figure this out after 10 hours of experimenting and thought I woud shared it here as the documentation for integrations with Bitbucket is virtually non-existent.

So my requirement:   Deploy an Angular2 app built with Angular-CLI to Azure on a checkin. It builds a DIST AOT build folder which needs to be tested and deployed to the root of your Azure App Service.

Firstly:  The Azure integration document here https://bitbucket.org/mojall/bitbucket-pipelines-deploy-to-azure is not well documented either. It is NOT an example of how to configure it - it is a VS Code extension to help configure it, which is not what I was looking for. I was able to dig in their source to extract the bits I needed:

Here is my Pipeline YAML:  I have left in the debugging statements that helped me figure out what was going on. (You can also enable npm test). The variables are from the Azure FTP publishing profile and go into BB Variables.

This chews through Build Minutes (around 8min per build) - I guess you could build a Docker image which already had your version of AngularCLI installed to save some time.

Hope this helps someone...

 

# http://gimly.github.io/azure/2016/12/27/bitbucket-pipelines-deploy-azure.html
# https://bitbucket.org/mojall/bitbucket-pipelines-deploy-to-azure/src/ac127659113e/artifacts/FTP/?at=master
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:5.11.0
pipelines:
default:
- step:
script:
- echo "Starting - DEV1 Build"
- pwd
- ls -al
- npm i -g angular-cli@1.0.0-beta.25.5
- npm i
#- npm test #if this passes then build package for deployment
- ng build --env=dev1 --aot # Build DEV1 Artifacts
- ls -al
- apt-get update # Now run the FTP bash script to deploy dist folder to DEV1
- apt-get install ncftp
- ncftpput -v -u "$FTP_USERNAME" -p "$FTP_PASSWORD" -R $FTP_HOST $FTP_SITE_ROOT dist/*
- echo Finished uploading /dist files to $FTP_HOST$FTP_SITE_ROOT

 


tesnep July 18, 2018

@Rodney Joyce This looks like it works but I am getting a "could not stat dist/*: No such file or directory." error. I check the logs and dist folder does get created. If I replace dist/* with * it starts copying everything across.

Did you have an issue with this? 

 

**UPDATE**

Didn't see that you had a single step. Should have copy pasted :). I find it a bit unusual that if I create Step 2 it will not find the newly created dist folder.

2 votes
Bruno Alexandre February 20, 2018

In order to save some minutes you can go with Kudu API and actually push into it:

image: node:8.9.4

pipelines:
default:
- step:
name: Build and test
caches:
- node
script: # install packages and run tests
- npm install
- npm test
- step:
name: Deploy to Azure
deployment: staging
script:
- git push https://$AZURE_LOGIN:$AZURE_PASSWORD@$AZURE_APP_NAME.scm.azurewebsites.net:443/$AZURE_APP_NAME.git master

 

credentials from Azure FTP Deployment saved as project variable in Bitbucket settings

more details on BitBucket docs

tesnep July 19, 2018

@Bruno Alexandre That works to push the source there but I get a runtime error. Do I add a web.config file telling it to route to the angular application? 

Bruno Alexandre September 28, 2018

@tesnep sorry, I got no notification you wrote here ... did you end up fixing it?

you should also run the build and updates right?

ng build
apt-get update

 

1 vote
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 12, 2016

Hi Rodney,

I'm not too knowledgeable on specifics with Azure. However, this page had some more information:

https://azure.microsoft.com/en-us/blog/continuous-integration-delivery-of-web-apps-from-atlassian-bitbucket/

It looks like you can run something in the VS Code extension you installed that will generate the required files for you to deploy to Azure from Bitbucket Pipelines.

Let me know your findings. Include the generated files here if you get stuck (remove any secrets first of course wink).

Good luck!

Phil

tesnep July 18, 2018

@Philip Hodder I tried using the extension and while it works (copies from all folders), I only want to copy from the dist folder. If I replace * with dist/* it says 

could not stat dist/*: No such file or directory.ncftpput dist/*: no valid files were specified.

 

**Update**

Turns out I needed to have this in a single step. When I list folders I do see it in Step 2 but ftp command does not find it. The other thing I would liked to have is not install the ftp program every time. That chews up the build time.

Like Gerhard Pretorius likes this
TAGS
AUG Leaders

Atlassian Community Events