I am compiling my c++ code. My requirement is to generate artifacts with two file. 1: Binary file 2: Readme file I am able to generate a binary file, but I am unable to generate a readme file in a specific format. Readme file contains build number in below format buildnumber = $a.$d.$e $a= build pipeline variable that can be set , $d =some incremental value, $e =git commit SHA like 669b7f8e
I don't want to use power shell “##vso[build.updatebuildnumber]build number”and put value.
my pipeline is :
variables:
- name: Version
value: 1
- name: VersionRevision
value: $[counter(variables['Version'], 0)]
- name: commitsha
value: $['Build.SourceVersion']
- name: build
value: mybuild
- name: buildnumber
value: $[ format('{0}.{1}.{2}', variables['build'], variables['VersionRevision'],variables['commitsha']) ]
trigger:
- master
jobs:
- job: gcctest
pool:
vmImage: 'ubuntu-16.04'
steps:
- script: sudo apt-get update && sudo apt-get install libboost-all-dev
- script: g++ -std=c++11 -I/usr/include/boost/asio -I/usr/include/boost -o result.out m.cpp
c.cpp d.cpp f.cpp
- bash: echo $(buildnumber)>test.txt
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: '?(*.out|*.txt)'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: result
$sha.substring(0,8)
to get the first 8 chars of the commit id. – Josh Gust