Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use the BB Pipelines Azure Deployment

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

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

 


@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.

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

@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? 

@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

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

@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

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you