Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .azure-pipelines/official-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ stages:
pool: sonicbld
variables:
CACHE_MODE: wcache
BRANCH_NAME: $(Build.SourceBranchName)
${{ if eq(variables['Build.SourceBranchName'], '202012') }}:
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web'
jobs:
Expand Down
1 change: 1 addition & 0 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ sonic_get_version() {
local describe=$(git describe --tags)
local latest_tag=$(git describe --tags --abbrev=0)
local branch_name=$(git rev-parse --abbrev-ref HEAD)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

branch_name

Do you know why the old code does not work? Is the local folder under git control?

Copy link
Copy Markdown
Collaborator Author

@xumia xumia Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When checking out code, the azure pipeline checkout task does not set the local branch name, looks like the azure pipelines not support it very well. But azure pipeline provides a environment variable build.SourceBranchName, it tells which branch the code checked-out from.

Azure Pipelines:
$ git branch -vv
(HEAD detached at ca072d2) ca072d2 Disable CI/CD trigger
vmss-soni00007E:/agent/_work/1/s$ git rev-parse --abbrev-ref HEAD
HEAD

Jenkins:
jenkins-worker-2:/data/johnar/workspace/broadcom/buildimage-brcm-all$ git branch -vv
master 32b5b02 [sonic-platform-daemons] Update submodule (#7277)
jenkins-worker-2:/data/johnar/workspace/broadcom/buildimage-brcm-all$ git rev-parse --abbrev-ref HEAD
master

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to address this from the azp script. otherwise, we have to cherry-pick this pr all the way to 201811 branch.

[ -n "$BRANCH_NAME" ] && branch_name=$BRANCH_NAME
if [ -n "$(git status --untracked-files=no -s --ignore-submodules)" ]; then
local dirty="-dirty-$BUILD_TIMESTAMP"
fi
Expand Down