@otr-app/start-pipeline
v1.0.0-beta.7
Published
Helper script that kicks of a pipeline
Keywords
Readme
@otr-app/start-pipeline
A utility package for managing AWS CodePipeline operations, providing command-line tools to start pipeline executions and retrieve information about successful deployments.
Overview
This package contains two main utilities:
- start-pipeline: Initiates a new pipeline execution with the current Git commit
- get-last-successful-commit: Retrieves the commit hash of a previous successful deployment
Installation
npm install @otr-app/start-pipelineUsage
start-pipeline
Starts a new AWS CodePipeline execution using the current Git commit as the source revision.
npx start-pipeline <pipeline-name>Example:
npx start-pipeline otr_frontendWhat it does:
- Gets the current Git commit hash (
git rev-parse HEAD) - Creates a new pipeline execution with the commit as the source revision
- Outputs the execution details
get-last-successful-commit
Retrieves the commit hash of a previous successful deployment from a specified pipeline and stage.
node dist/get-last-successful-commit [n-deploys] [pipeline-name] [stage-name]Parameters:
n-deploys(optional): Number of deployments to look back (default: 0 for the most recent)pipeline-name(optional): Name of the pipeline (default:otr_frontend)stage-name(optional): Name of the stage to check (default:deploy)
Examples:
# Get the most recent successful commit on otr_frontend
node dist/get-last-successful-commit
# Get the commit from 2 deployments ago on otr_frontend
node dist/get-last-successful-commit 2
# Get the commit from a specific pipeline and stage
node dist/get-last-successful-commit 0 otr_backend_service_mono DevoWhat it does:
- Queries AWS CodePipeline for successful executions in the specified stage
- Extracts commit hashes from the execution source revisions
- Returns the commit hash at the specified position (0 = most recent, 1 = previous, etc.)
Configuration
The package uses the following default settings (defined in settings.ts):
- Default Region:
us-east-1 - Root Pipeline Name:
otr_frontend
Prerequisites
- AWS credentials configured (via AWS CLI, environment variables, or IAM roles)
- Access to the specified AWS CodePipeline
- Git repository with commit history
AWS Permissions
The following AWS permissions are required:
For start-pipeline:
codepipeline:StartPipelineExecution
For get-last-successful-commit:
codepipeline:GetPipelinecodepipeline:ListPipelineExecutions
Error Handling
Both commands will exit with code 1 if they encounter errors:
- Invalid pipeline names
- Missing AWS credentials
- Network connectivity issues
- Invalid command arguments
Development
Building
npm run buildDependencies
@aws-sdk/client-codepipeline: AWS SDK for CodePipeline operationstypescript: TypeScript compiler
License
ISC
