diff --git a/devops/pipeline/binary_package.yaml b/devops/pipeline/binary_package.yaml index 9cc773e3b5..6bbdb5ee2c 100644 --- a/devops/pipeline/binary_package.yaml +++ b/devops/pipeline/binary_package.yaml @@ -98,6 +98,11 @@ trigger: pr: none stages: +- template: stages/source_build.yaml + parameters: + containerPath: $(CONTAINER_REGISTRY)/ubuntu20.04-dev-amd64:latest + publishArtifact: true + - ${{ each target in parameters.build_targets }}: - template: stages/binary_build.yaml parameters: diff --git a/devops/pipeline/stages/source_build.yaml b/devops/pipeline/stages/source_build.yaml new file mode 100644 index 0000000000..e53648c346 --- /dev/null +++ b/devops/pipeline/stages/source_build.yaml @@ -0,0 +1,64 @@ +# Source build stage definition +# Parameters: +# - (Required) containerPath [string]: the full path to the container to be used for the build environmentr (Example. osconfig.azurecr.io/ubuntu20.04-dev-amd64:latest) +# - (Optional) prefix [string]: the prefix for the stage/job to be used - default: source +# - (Optional) publishArtifact [boolean]: publishes the built artifacts (packages) as pipeline artifacts - default: true + +parameters: + - name: prefix + type: string + default: source + + - name: containerPath + type: string + + - name: publishArtifact + type: boolean + default: false + +stages: +- stage: source_build + displayName: Source + dependsOn: [] + + jobs: + - job: ${{ parameters.prefix }} + + pool: + vmImage: 'ubuntu-20.04' + + steps: + + - checkout: self + submodules: recursive + clean: true + + - task: Docker@2 + displayName: Login to ACR + inputs: + command: login + containerRegistry: $(SERVICE_CONNECTION) + + - script: | + CONTAINER_ID=`docker run -di -v $(Build.SourcesDirectory):/AzOsConfig ${{ parameters.containerPath }}` + echo CONTAINER_ID=$CONTAINER_ID + echo "##vso[task.setvariable variable=CONTAINER_ID]$CONTAINER_ID" + # Extract TWEAK version from full version string + BUILD_VERSION_ARRAY=(`echo $(Build.BuildNumber) | tr '.' ' '`) + TWEAK_VERSION=${BUILD_VERSION_ARRAY[-1]} + echo TWEAK_VERSION=$TWEAK_VERSION + echo "##vso[task.setvariable variable=TWEAK_VERSION]$TWEAK_VERSION" + displayName: Container Setup + + - script: | + docker exec $(CONTAINER_ID) bash -c "cmake -DCMAKE_BUILD_TYPE=Release -Duse_prov_client=ON -Dhsm_type_symm_key=ON -DCOMPILE_WITH_STRICTNESS=ON -DMAJOR_VERSION=$(MAJORVERSION) -DMINOR_VERSION=$(MINORVERSION) -DPATCH_VERSION=$(PATCHVERSION) -DTWEAK_VERSION=$(TWEAK_VERSION) -G Ninja -B/AzOsConfig/build -H/AzOsConfig/src" + displayName: Generate build + + - script: | + docker exec $(CONTAINER_ID) bash -c "cd /AzOsConfig/build && cmake --build . && cmake --build . --target dist && mkdir staging && cp -r /AzOsConfig/build/dist/* staging" + displayName: Build & Stage Source Package + + - publish: $(Build.SourcesDirectory)/build/staging + displayName: Publishing source package + artifact: OSConfig_$(Build.BuildNumber)_SOURCES + condition: eq(${{ parameters.publishArtifact }}, true) \ No newline at end of file