Building .NET Core apps with BitBucket Pipelines and Docker

Building .NET Core apps with BitBucket Pipelines and Docker

Recently, I started researching tools and services for the build automation. Being a long user of TeamCity and currently Travis CI (also had some experience with Jenkins, AppVeyor and VSTS) I wanted to find out what else is there. Then I realized that there’s a build server built into BitBucket, thus I decided to give it a go.


 

BitBucket Pipelines is a part of BitBucket cloud and hosted repository either for Git or Mercurial projects. There’s no need to install or download anything – just click enable Pipelines and that’s it. What I wanted to achieve is the following, a rather typical scenario – after each commit to the repository, assuming that the specific Git branch was updated, the service should build the app, test it and then build a Docker image and publish it to the Docker Hub or any other registry e.g. Azure Container Registry.

And I wanted to do it in the simplest way possible – as much as I like TeamCity, there’s a lot of things required to get things done, in opposite to e.g Travis CI. Therefore, I really wanted to define my overall build flow in a single file if possible and just don’t care about anything else. So this is what my bitbucket-pipelines.yml eventually looked like (which has to be placed in the root of the repository):

As you can see, there’s an easy way to access the environment variables. Both, the DOCKER_USERNAME and DOCKER_PASSWORD were defined as the secured variables within my account settings in the repository, as I do not want to push the username or password to my repository at all. And if you’d like to define some environment variables in the configuration file, you can do it easily using the export keyword, for example like this:

And of course, you can access the system variables like the name of the branch using BITBUCKET_BRANCH or hash of the commit BITBUCKET_COMMIT that might be especially useful for tagging the project versions.

Pipelines builds are really fast and for me, that really matters. So where’s the catch? Using the free version you can access only 50 minutes monthly for the build services, however for 10$ monthly (2$ per user starting from 5 users) you can already make use of 500 minutes, so you should be fine.

23 Comments Building .NET Core apps with BitBucket Pipelines and Docker

  1. Pingback: Building .NET Core apps with BitBucket Pipelines and Docker - How to Code .NET

  2. Pingback: Dew Drop - June 19, 2017 (#2503) - Morning Dew

  3. Pingback: Hosting Docker images on Azure Container Registry | Piotr Gankiewicz

  4. pc.Vshare

    What build tools do people use for .NET these days? When I last coded C# a couple years back, MS Build was pervasive, like it or not. But we liked to use a layer over it like psake or fake. Are people using those or others?

    Reply
  5. inigojoseph

    Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.

    Reply
  6. ummayashri

    I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.

    Reply
  7. VRIT Professional

    Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.

    Thanks & Regards,
    VRIT Professionals,
    No.1 Leading Web Designing Training Institute In Chennai.

    And also those who are looking for
    Web Designing Training Institute in Chennai
    SEO Training Institute in Chennai
    PHP & Mysql Training Institute in Chennai
    Photoshop Training Institute in Chennai
    Android Training Institute in Chennai

    Reply
  8. Vishwa

    Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things…Really it was an awesome article…very interesting to read..please sharing like this information……

    Reply
  9. sivasundari

    The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea.
    here by i also want to share this.

    Reply
  10. Ramya

    This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information regarding Microsoft Azure which is latest and newest,

    Regards,
    Ramya

    Azure Training in Chennai
    Azure Training Center in Chennai
    Best Azure Training in Chennai
    Azure Devops Training in Chenna
    Azure Training Institute in Chennai
    Azure Training in Chennai OMR
    Azure Training in Chennai Velachery
    Azure Online Training
    Azure Training in Chennai Credo Systemz

    Reply
  11. Aman CSE

    Appericated the efforts you put in the content of Data Science .The Content provided by you for Data Science is up to date and its explained in very detailed for Data Science like even beginers can able to catch.Requesting you to please keep updating the content on regular basis so the peoples who follwing this content for Data Science can easily gets the updated data.
    Thanks and regards,
    Data Science training in Chennai
    Data Science course in chennai with placement
    Data Science certification in chennai
    Data Science course in Omr

    Reply

Leave A Comment

Your email address will not be published. Required fields are marked *