Pipeline: Repository Variables in GitHub Bitbucket for Version Info

Home / Blogs / Pipeline: Repository Variables in GitHub Bitbucket for Version Info

Recently I’ve been working a lot with pipelines to automate the build aspects of a LabVIEW framework development and it’s quite interesting how it all takes in various directions. To be frank, I think there are too many options when you come into this world from a fixed monolithic application world. Anyways a new learning today is the repository variables used as version info.

LabVIEW Project & Version Limitation

When it comes to LabVIEW (or maybe in other environments too, I’m not sure), you can save the version info of a built config only to the source file, ie., .lvproj in the LabVIEW case. You can’t change this version info in the .lvproj file after your build server builds the executable because you usually don’t want the build server to commit any files to the repository.

While building any executable, we increment or change the version semantics during the build, so we want a place to store this after-build version info. One good option I found now is to use the repository variable with which we can maintain this info so that subsequent builds can read that variable and increment. Both GitHub and Bitbucket offer such repository variables.

Permission, Access & Scopes

The access permission for the pipeline is also quite important. You need to have the Pipeline access permission to read/write/admin when you create the App Password. If it’s Write Access, ensure your account in itself has admin/write access to the repo you’re trying to access from. It’s multi-level privileges and access scopes you need to understand.

API with curly braces input

We would need to use Variable Accessing APIs in Bitbucket to read or change this. Always use Postman to get it tested. One niche thing I found is sometimes there are variables in the CURL which has to include curly braces { } and it’s not explicit in these APIs. I figured out that you need to change it to ASCII as

  • %7B for the open curly brace and
  • %7D for a close curly brace.

For example to apply for the write variable API,

https://your_username:your_app_password@api.bitbucket.org/2.0/repositories/repository_workspace/repository/pipelines_config/variables/%7Bvariable_uuid%7D

Leave a Reply

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