From 7d56791f64a6be1a9cf0885291c61c2ebf80ce97 Mon Sep 17 00:00:00 2001 From: Samiya Akhtar Date: Mon, 13 Apr 2020 14:02:56 -0700 Subject: [PATCH 1/3] Handle the case where multiple PRs are present --- tests/functions.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/functions.sh b/tests/functions.sh index 1fa7c72b..917be916 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -531,12 +531,15 @@ function approve_pull_request () { all_prs="${all_prs//\\n/}" #Escape the JSON result pr_exists=$(echo $all_prs | sed 's/\\r\\n//g' | jq -r --arg pr_title "$pr_title" '.[].title | select(startswith($pr_title)) != null') + echo "pr_exists=$pr_exists" if [ "$pr_exists" != "true" ]; then - echo "PR for '$pr_title' not found" - exit 1 + if [ $pr_exists != *"true"* ]; then + echo "PR for '$pr_title' not found" + exit 1 + fi fi real_title=$(echo $all_prs | jq -r --arg pr_title "$pr_title" 'select(.[].title | startswith($pr_title)) | .[].title' | head -n 1) - pull_request_id=$(echo $all_prs | jq -r --arg pr_title "$pr_title" 'select(.[].title | startswith($pr_title)) | .[0].pullRequestId') + pull_request_id=$(echo $all_prs | jq -r --arg pr_title "$pr_title" 'select(.[0].title | startswith($pr_title)) | .[0].pullRequestId') echo "Found pull request starting with phrase '$pr_title'" echo "Pull request id $pull_request_id is '$real_title'" From 9d0fe6acf9cc8805bfe96a6e9c8c8f2e318483b8 Mon Sep 17 00:00:00 2001 From: Samiya Akhtar Date: Mon, 13 Apr 2020 14:19:44 -0700 Subject: [PATCH 2/3] Remove log statement --- tests/functions.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functions.sh b/tests/functions.sh index 917be916..0e48d378 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -531,7 +531,6 @@ function approve_pull_request () { all_prs="${all_prs//\\n/}" #Escape the JSON result pr_exists=$(echo $all_prs | sed 's/\\r\\n//g' | jq -r --arg pr_title "$pr_title" '.[].title | select(startswith($pr_title)) != null') - echo "pr_exists=$pr_exists" if [ "$pr_exists" != "true" ]; then if [ $pr_exists != *"true"* ]; then echo "PR for '$pr_title' not found" From 24c437911b1a8c9d472bb92f9c0b7b69cf7162e4 Mon Sep 17 00:00:00 2001 From: Andre Briggs Date: Tue, 14 Apr 2020 09:58:02 -0700 Subject: [PATCH 3/3] [DOCS] Adding Markdown file for spk deployment create (#7) * Added create.md * Update * Adding command examples about other pipelines Co-authored-by: Dennis Seah Co-authored-by: Yvonne Radsmikham Co-authored-by: Samiya Akhtar --- docs/commands/data.json | 5 +-- src/commands/deployment/create.md | 43 +++++++++++++++++++++++ src/commands/hld/append-variable-group.md | 2 -- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/commands/deployment/create.md diff --git a/docs/commands/data.json b/docs/commands/data.json index 28f66592..d37cf480 100644 --- a/docs/commands/data.json +++ b/docs/commands/data.json @@ -94,7 +94,8 @@ "arg": "--repository ", "description": "URL of the repository (SRC, HLD, Manifest)" } - ] + ], + "markdown": "## Description\n\nThis command inserts data about pipeline runs into Azure Table storage.\n\n## Example\n\nThe following command has parameters for Azure Table storage credential and\nvarious pipelines run details.\n\n```\nspk deployment create -n $AZURE_STORAGE_ACCOUNT_NAME \\\n -k $AZURE_ACCOUNT_KEY \\\n -t $AZURE_TABLE_NAME \\\n -p $AZURE_TABLE_PARTITION_KEY \\\n --p2 $(Build.BuildId) \\\n --hld-commit-id $latest_commit \\\n --env $(Build.SourceBranchName) \\\n --image-tag $tag_name \\\n --pr $pr_id \\\n --repository $repourl\n```\n" }, "deployment dashboard": { "command": "dashboard", @@ -237,7 +238,7 @@ "command": "append-variable-group ", "alias": "avg", "description": "Appends the name of an existing variable group to the current manifest-generation.yaml file.", - "markdown": "## Description\n\nAppend a variable group name to the current `manifest-generation.yaml` of an\ninitialized hld repository.\n\n## Example\n\nWhen an HLD repository is first initialized with `spk hld init`, the top portion\nof the `manifest-generation.yaml` looks like this:\n\n```yaml\n# GENERATED WITH SPK VERSION 0.5.8\ntrigger:\n branches:\n include:\n - master\nvariables: []\npool:\n vmImage: ubuntu-latest\nsteps:\n.\n.\n.\n```\n\nrunning `spk hld append-variable-group my-vg` with a variable group name, in\nthis case `my-vg`, will add it under the `variables` section if it does not\nalready exist:\n\n```yaml\n# GENERATED WITH SPK VERSION 0.5.8\ntrigger:\n branches:\n include:\n - master\nvariables:\n - group: my-variable-group\npool:\n vmImage: ubuntu-latest\nsteps:\n.\n.\n.\n```\n" + "markdown": "## Description\n\nAppend a variable group name to the current `manifest-generation.yaml` of an\ninitialized hld repository.\n\n## Example\n\nWhen an HLD repository is first initialized with `spk hld init`, the top portion\nof the `manifest-generation.yaml` looks like this:\n\n```yaml\ntrigger:\n branches:\n include:\n - master\nvariables: []\npool:\n vmImage: ubuntu-latest\nsteps:\n.\n.\n.\n```\n\nrunning `spk hld append-variable-group my-vg` with a variable group name, in\nthis case `my-vg`, will add it under the `variables` section if it does not\nalready exist:\n\n```yaml\ntrigger:\n branches:\n include:\n - master\nvariables:\n - group: my-variable-group\npool:\n vmImage: ubuntu-latest\nsteps:\n.\n.\n.\n```\n" }, "hld init": { "command": "init", diff --git a/src/commands/deployment/create.md b/src/commands/deployment/create.md new file mode 100644 index 00000000..1cd8db4a --- /dev/null +++ b/src/commands/deployment/create.md @@ -0,0 +1,43 @@ +## Description + +This command inserts data about pipeline runs into Azure Table storage. + +## Example + +The following command has parameters for Azure Table storage credential and various pipelines run details. It's used by the source build pipeline, the release stage and the manifest generation pipeline, and each of them pass in parameters depending on the information for that pipeline. Here are three examples: + +``` +spk deployment create -n $AZURE_STORAGE_ACCOUNT_NAME \ + -k $AZURE_ACCOUNT_KEY \ + -t $AZURE_TABLE_NAME \ + -p $AZURE_TABLE_PARTITION_KEY \ + --p1 $(Build.BuildId) \ + --image-tag $tag_name \ + --commit-id $commitId \ + --service $service \ + --repository $repourl +``` + +``` +spk deployment create -n $AZURE_STORAGE_ACCOUNT_NAME \ + -k $AZURE_ACCOUNT_KEY \ + -t $AZURE_TABLE_NAME \ + -p $AZURE_TABLE_PARTITION_KEY \ + --p2 $(Build.BuildId) \ + --hld-commit-id $latest_commit \ + --env $(Build.SourceBranchName) \ + --image-tag $tag_name \ + --pr $pr_id \ + --repository $repourl +``` + +``` +spk deployment create -n $AZURE_STORAGE_ACCOUNT_NAME \ + -k $AZURE_ACCOUNT_KEY \ + -t $AZURE_TABLE_NAME \ + -p $AZURE_TABLE_PARTITION_KEY \ + --p3 $(Build.BuildId) \ + --hld-commit-id $commitId \ + --pr $pr_id \ + --repository $repourl +``` diff --git a/src/commands/hld/append-variable-group.md b/src/commands/hld/append-variable-group.md index 45fcaa09..e0641573 100644 --- a/src/commands/hld/append-variable-group.md +++ b/src/commands/hld/append-variable-group.md @@ -9,7 +9,6 @@ When an HLD repository is first initialized with `spk hld init`, the top portion of the `manifest-generation.yaml` looks like this: ```yaml -# GENERATED WITH SPK VERSION 0.5.8 trigger: branches: include: @@ -28,7 +27,6 @@ this case `my-vg`, will add it under the `variables` section if it does not already exist: ```yaml -# GENERATED WITH SPK VERSION 0.5.8 trigger: branches: include: