- Newest
- Most votes
- Most comments
Hi, Lets say you have an existing pipeline which gets triggered automatically on every push. To stop the automatic triggers, you will have to find a cloudwatch event rule that is associated with the pipeline. You can disable that rule to stop automatic triggers.
If you want to start the pipeline on a specific commit id, you can use the following command using awscli
aws codepipeline start-pipeline-execution \
--name <pipeline-name> \
--client-request-token <unique-token> \
--source-revision revisions='[{"actionName":"<source-stage-action-name>","revisionId":"<commit-id>"}]'
Here you can specify the name of Source stage in source-stage-action-name and that would trigger the entire pipeline(not just source stage)
Make sure before you run the the command, awscli has required permissions.
Below are the list of permissions that might be required:
codepipeline:StartPipelineExecution
If the code is hosted on codecommit:
codecommit:GetCommit
codecommit:GetBranch
codecommit:GitPull
If the code is hosted on Github:
codepipeline:PollForSourceChanges
codepipeline:RetryStageExecution
There might be more permissions needed so please make sure the awscli has the required permissions
Hello, yes this can be done, by implementing the following:
- Create a CodePipeline with a CodeCommit source stage.
- Set the PollForSourceChanges parameter to false to prevent automatic triggering.
- Remove any CloudWatch Events rules that might trigger the pipeline automatically.
You can then use the AWS CLI to manually start the pipeline from a specific commit. Here's an example BASH script:
#!/bin/bash
# Replace these variables with your actual values
PIPELINE_NAME="YourPipelineName"
REPOSITORY_NAME="YourRepositoryName"
BRANCH_NAME="YourBranchName"
# Function to start the pipeline execution
start_pipeline_execution() {
local commit_id=$1
aws codepipeline start-pipeline-execution \
--name $PIPELINE_NAME \
--client-request-token $(date +%s) \
--source-revision "{\"type\": \"CodeCommit\", \"revisionType\": \"String\", \"revisionValue\": \"$commit_id\"}"
}
# Check if commit ID is provided
if [ $# -eq 0 ]; then
echo "Please provide a commit ID"
exit 1
fi
COMMIT_ID=$1
# Start the pipeline execution
start_pipeline_execution $COMMIT_ID
echo "Pipeline execution started for commit: $COMMIT_ID"
Ensure your AWS CLI is configured with the necessary permissions to start pipeline executions. The IAM role associated with your pipeline must have permissions to access the specified commit in the CodeCommit repository. You may need to adjust the region in the AWS CLI command if your pipeline is not in the default region.
Hi. You can use input parameters as well: https://aws.amazon.com/about-aws/whats-new/2023/10/aws-codepipeline-parameterized-pipelines/#:~:text=Today%2C%20AWS%20CodePipeline%20announces%20the%20general%20availability%20of,the%20variables%20and%20use%20them%20in%20action%20configurations.
Relevant content
- AWS OFFICIALUpdated a year ago
