Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.

Commit d1fb8f9

Browse files
committed
Added README
1 parent cf9cdfb commit d1fb8f9

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
1-
# aws-codepipeline-custom-job-worker
2-
Use this sample to help you develop your own job worker when creating a custom action for AWS CodePipeline. For more information, see Create a Custom Action for a Pipeline. http://docs.aws.amazon.com/codepipeline/latest/userguide/how-to-create-custom-action.html
1+
# AWS CodePipeline Job Worker
2+
Read more about CodePipeline: http://aws.amazon.com/codepipeline/
3+
4+
## Build
5+
### Dependencies
6+
Install the following tools to build the AWS CodePipeline Job Worker:
7+
- Java SE Development Kit 8
8+
- Apache Ant
9+
10+
### Ant targets
11+
You can use the following ant targets to build the code:
12+
```bash
13+
ant clean # Cleans the workspace
14+
ant compile # Compiles the code
15+
ant junit # Runs the unit tests
16+
ant jar # Creates the jar file
17+
ant release # Default target, which compiles the code, runs the unit tests, creates the jar file and deployment bundle
18+
```
19+
20+
## Start
21+
Use the init.d script to start the AWS CodePipeline Job Worker polling for custom actions:
22+
```bash
23+
service aws-codepipeline-jobworker start
24+
```
25+
26+
The script optionally takes the configuration class as a parameter. If you want to run the job worker for third party actions, you can use the following command:
27+
```bash
28+
service aws-codepipeline-jobworker start "com.amazonaws.codepipeline.jobworker.configuration.ThirdPartyJobWorkerConfiguration"
29+
```
30+
31+
You can also specify your own configuration class. It only has to implement the `JobWorkerConfiguration` interface.
32+
33+
## Configuration
34+
The job worker comes with two pre-defined configuration classes: `CustomActionJobWorkerConfiguration` and `ThirdPartyJobWorkerConfiguration`. Both inherit from the `DefaultJobWorkerConfiguration` to share most of the configuration settings.
35+
36+
You can configure the following settings:
37+
```java
38+
// Configure action type the job worker polls for
39+
public ActionType getActionType() {
40+
return new ActionType(
41+
"Deploy", // Action Type Category: Source, Build, Test, Deploy, Invoke
42+
"Custom", // Action Type Owner: Custom or ThirdParty
43+
"MyCustomAction", // Action Type Provider: Name of your action type
44+
"1" // Action Type Version: e.g. "1"
45+
);
46+
}
47+
48+
// How frequently the job worker polls for new jobs
49+
private static final long POLL_INTERVAL_MS = 5000L; // e.g. every 5 seconds
50+
51+
// Maximum number of worker threads. Indicates how many jobs can be processed in parallel.
52+
private static final int WORKER_THREADS = 10;
53+
54+
// The AWS region of AWS CodePipeline. The job worker polls for jobs in this region.
55+
private static final Region AWS_REGION = Region.getRegion(Regions.US_EAST_1);
56+
```
57+
58+
## Deployment
59+
The job worker comes with AWS CodeDeploy installation scripts. Set up your application and deployment group in AWS CodeDeploy and run the following command to deploy the agent:
60+
```bash
61+
# Replace with your Amazon S3 bucket name
62+
AMAZON_S3_BUCKET=<your-amazon-s3-bucket>
63+
# Make sure that you set up your application and deployment group in AWS CodeDeploy
64+
APPLICATION_NAME=AwsCodePipelineJobWorker
65+
DEPLOYMENT_GROUP_NAME=Production
66+
67+
# Compile the code and create deployment bundle
68+
ant release
69+
70+
# Create a tar archive from the build output
71+
cd build/output
72+
tar -cf ../AwsCodePipelineJobWorker.tar *
73+
74+
# Upload the deployment bundle to your Amazon S3 bucket.
75+
aws s3 cp ../AwsCodePipelineJobWorker.tar s3://$AMAZON_S3_BUCKET/AwsCodePipelineJobWorker.tar
76+
77+
# Start the deployment using AWS CodeDeploy
78+
aws deploy create-deployment --application-name $APPLICATION_NAME --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=$AMAZON_S3_BUCKET,bundleType=tar,key=AwsCodePipelineJobWorker.tar
79+
```

0 commit comments

Comments
 (0)