@@ -53,6 +53,17 @@ export const createTestServiceBuildAndUpdatePipelineYaml = (
5353 ] ) ,
5454 displayName : "Azure Login"
5555 } ,
56+ {
57+ script : generateYamlScript ( [
58+ `# Download build.sh` ,
59+ `curl $BEDROCK_BUILD_SCRIPT > build.sh` ,
60+ `chmod +x ./build.sh`
61+ ] ) ,
62+ displayName : "Download bedrock bash scripts" ,
63+ env : {
64+ BEDROCK_BUILD_SCRIPT : "$(BUILD_SCRIPT_URL)"
65+ }
66+ } ,
5667 {
5768 script : generateYamlScript ( [
5869 `export BUILD_REPO_NAME=${ BUILD_REPO_NAME ( serviceName ) } ` ,
@@ -63,9 +74,6 @@ export const createTestServiceBuildAndUpdatePipelineYaml = (
6374 `service=\${service##*/}` ,
6475 `url=$(git remote --verbose | grep origin | grep fetch | cut -f2 | cut -d' ' -f1)` ,
6576 `repourl=\${url##*@}` ,
66- `echo "Downloading SPK"` ,
67- `curl https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh > build.sh` ,
68- `chmod +x build.sh` ,
6977 `. ./build.sh --source-only` ,
7078 `get_spk_version` ,
7179 `download_spk` ,
@@ -178,7 +186,6 @@ export const createTestServiceBuildAndUpdatePipelineYaml = (
178186 `response=$(az repos pr create --description "Updating $SERVICE_NAME_LOWER to ${ IMAGE_TAG } ." "PR created by: $(Build.DefinitionName) with buildId: $(Build.BuildId) and buildNumber: $(Build.BuildNumber)")` ,
179187 `pr_id=$(echo $response | jq -r '.pullRequestId')` ,
180188 `` ,
181- `` ,
182189 `# Update introspection storage with this information, if applicable` ,
183190 `if [ -z "$(INTROSPECTION_ACCOUNT_NAME)" -o -z "$(INTROSPECTION_ACCOUNT_KEY)" -o -z "$(INTROSPECTION_TABLE_NAME)" -o -z "$(INTROSPECTION_PARTITION_KEY)" ]; then` ,
184191 `echo "Introspection variables are not defined. Skipping..."` ,
@@ -187,10 +194,6 @@ export const createTestServiceBuildAndUpdatePipelineYaml = (
187194 `tag_name="$BUILD_REPO_NAME:$(Build.SourceBranchName)-$(Build.BuildNumber)"` ,
188195 `url=$(git remote --verbose | grep origin | grep fetch | cut -f2 | cut -d' ' -f1)` ,
189196 `repourl=\${url##*@}` ,
190- `echo "Downloading SPK"` ,
191- `curl https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh > build.sh` ,
192- `chmod +x build.sh` ,
193- `. ./build.sh --source-only` ,
194197 `get_spk_version` ,
195198 `download_spk` ,
196199 `./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p2 $(Build.BuildId) --hld-commit-id $latest_commit --env $BRANCH_NAME --image-tag $tag_name --pr $pr_id --repository $repourl` ,
@@ -430,6 +433,26 @@ export const createTestHldAzurePipelinesYaml = (
430433 BEDROCK_BUILD_SCRIPT : "$(BUILD_SCRIPT_URL)"
431434 }
432435 } ,
436+ {
437+ script : generateYamlScript ( [
438+ `commitId=$(Build.SourceVersion)` ,
439+ `commitId=$(echo "\${commitId:0:7}")` ,
440+ `. ./build.sh --source-only` ,
441+ `get_spk_version` ,
442+ `download_spk` ,
443+ `message="$(Build.SourceVersionMessage)"` ,
444+ `if [[ $message == *"Merged PR"* ]]; then` ,
445+ `pr_id=$(echo $message | grep -oE '[0-9]+' | head -1 | sed -e 's/^0\\+//')` ,
446+ `./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p3 $(Build.BuildId) --hld-commit-id $commitId --pr $pr_id` ,
447+ `else` ,
448+ `./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p3 $(Build.BuildId) --hld-commit-id $commitId` ,
449+ `fi`
450+ ] ) ,
451+ displayName :
452+ "If configured, update manifest pipeline details in Spektate db before manifest generation" ,
453+ condition :
454+ "and(ne(variables['INTROSPECTION_ACCOUNT_NAME'], ''), ne(variables['INTROSPECTION_ACCOUNT_KEY'], ''),ne(variables['INTROSPECTION_TABLE_NAME'], ''),ne(variables['INTROSPECTION_PARTITION_KEY'], ''))"
455+ } ,
433456 {
434457 task : "ShellScript@2" ,
435458 displayName : "Validate fabrikate definitions" ,
@@ -458,28 +481,17 @@ export const createTestHldAzurePipelinesYaml = (
458481 } ,
459482 {
460483 script : generateYamlScript ( [
484+ `. ./build.sh --source-only` ,
461485 `cd "$HOME"/\${MANIFEST_REPO##*/}` ,
462- `commitId=$(Build.SourceVersion)` ,
463- `commitId=$(echo "\${commitId:0:7}")` ,
464486 `latest_commit=$(git rev-parse --short HEAD)` ,
465487 `url=$(git remote --verbose | grep origin | grep fetch | cut -f2 | cut -d' ' -f1)` ,
466488 `repourl=\${url##*@}` ,
467- `echo "Downloading SPK"` ,
468- `curl https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh > build.sh` ,
469- `chmod +x build.sh` ,
470- `. ./build.sh --source-only` ,
471489 `get_spk_version` ,
472490 `download_spk` ,
473- `message="$(Build.SourceVersionMessage)"` ,
474- `if [[ $message == *"Merged PR"* ]]; then` ,
475- `pr_id=$(echo $message | grep -oE '[0-9]+' | head -1 | sed -e 's/^0\\+//')` ,
476- `./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p3 $(Build.BuildId) --hld-commit-id $commitId --manifest-commit-id $latest_commit --pr $pr_id --repository $repourl` ,
477- `else` ,
478- `./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p3 $(Build.BuildId) --hld-commit-id $commitId --manifest-commit-id $latest_commit --repository $repourl` ,
479- `fi`
491+ `./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p3 $(Build.BuildId) --manifest-commit-id $latest_commit --repository $repourl`
480492 ] ) ,
481493 displayName :
482- "If configured, update manifest pipeline details in Spektate db" ,
494+ "If configured, update manifest pipeline details in Spektate db after manifest generation " ,
483495 condition :
484496 "and(ne(variables['INTROSPECTION_ACCOUNT_NAME'], ''), ne(variables['INTROSPECTION_ACCOUNT_KEY'], ''),ne(variables['INTROSPECTION_TABLE_NAME'], ''),ne(variables['INTROSPECTION_PARTITION_KEY'], ''))"
485497 }
0 commit comments