Skip to content

Commit

Permalink
Merge pull request #126 from theserverlessway/feature/build-limits
Browse files Browse the repository at this point in the history
Add option to limit number of codebuild builds, set to 10 by default
  • Loading branch information
flomotlik authored Dec 14, 2023
2 parents fa0d3c5 + 4c1364a commit a43b5c6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Following is a list of all available commands and links to their source document
* [`codebuild`](https://github.com/theserverlessway/awsinfo/blob/master/scripts/commands/codebuild/index.md)
* [`codebuild build`](https://github.com/theserverlessway/awsinfo/blob/master/scripts/commands/codebuild/build.md)
* [`codebuild build-reports`](https://github.com/theserverlessway/awsinfo/blob/master/scripts/commands/codebuild/build-reports.md)
* [`codebuild build-status`](https://github.com/theserverlessway/awsinfo/blob/master/scripts/commands/codebuild/build-status.md)
* [`codebuild builds`](https://github.com/theserverlessway/awsinfo/blob/master/scripts/commands/codebuild/builds.md)
* [`codebuild report`](https://github.com/theserverlessway/awsinfo/blob/master/scripts/commands/codebuild/report.md)
* [`codebuild report-groups`](https://github.com/theserverlessway/awsinfo/blob/master/scripts/commands/codebuild/report-groups.md)
Expand Down
10 changes: 10 additions & 0 deletions scripts/commands/codebuild/build-status.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source $CURRENT_COMMAND_DIR/build_selection.sh

awscli codebuild batch-get-builds --output table --ids $SELECTED --query "builds[].{
\"1.Id\":id,
\"2.Number\":buildNumber,
\"3.Phase\":currentPhase,
\"4.Status\":buildStatus,
\"5.StartedAt\":startTime,
\"6.FinishedAt\":endTime,
\"7.Environment\":environment}"
11 changes: 11 additions & 0 deletions scripts/commands/codebuild/build-status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `awsinfo codebuild build-status [first-filters]+ -- [second-filters]*`

Show only the status and most relevant data of a build

## First Filter matches against

* Project Name

## Second Filter matches against

* Build Id
2 changes: 1 addition & 1 deletion scripts/commands/codebuild/build_selection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ select_one Project "$PROJECTS"

BUILD_IDS=$(awscli codebuild list-builds-for-project --project-name "$SELECTED" --max-items 100 --output text --query "ids[$(auto_filter_joined @ -- "$SECOND_RESOURCE")].[@]")

select_one Build "$BUILD_IDS"
select_one_unsorted Build "$BUILD_IDS"
12 changes: 11 additions & 1 deletion scripts/commands/codebuild/builds.bash
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
MAX_BUILDS="10"

while getopts "m:" opt; do
case "$opt" in
m) MAX_BUILDS="$OPTARG" ;;
esac
done

shift "$(($OPTIND - 1))"

split_args "$@"

PROJECTS=$(awscli codebuild list-projects --output text --query "projects[$(auto_filter_joined @ -- "$FIRST_RESOURCE")].[@]")

select_one Project "$PROJECTS"

BUILD_IDS=$(awscli codebuild list-builds-for-project --max-items 99 --project-name "$SELECTED" --output text --query "ids[].[@]" | head -n 99 )
BUILD_IDS=$(awscli codebuild list-builds-for-project --max-items "$MAX_BUILDS" --project-name "$SELECTED" --output text --query "ids[].[@]" | sed '$d' )

awscli codebuild batch-get-builds --output table --query "reverse(builds)[$(auto_filter_joined id buildNumber currentPhase buildStatus -- "$SECOND_RESOURCE")].{
\"1.Id\":id,
Expand Down
4 changes: 4 additions & 0 deletions scripts/commands/codebuild/builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

List all builds for a project

## Options

* `-m`: Number of builds to show

## Filter matches against

* Project Name

0 comments on commit a43b5c6

Please sign in to comment.