I have a pipeline configured to use the ThridParty GitHub source provider as follows:
...
Resources:
DevPipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: my-pipeline
RoleArn: !Ref 'PipelineRole'
Stages:
- Name: Source
Actions:
- Name: GitHub
ActionTypeId:
Category: Source
Owner: ThirdParty
Version: 1
Provider: GitHub
Configuration:
Owner: !Ref GitHubOwner
Repo: !Ref GitHubRepo
Branch: !Ref GitHubBranch
OAuthToken: !Ref GitHubToken
OutputArtifacts:
- Name: JavaSource
RunOrder: 1
...
I would like to be able to run git
operations on the source code in the following build steps. However this source action does not include the .git
folder in the output artifact.
How can I modify this so that I can access git
operations on the repo?
CodePipeline recently released new version of the GitHub Source action that does an actual clone of git repository instead of getting the 'zip' bundle from GitHub.
The new GitHub action (version 2) uses the CodeStarSourceConnection. So we just need to specify the CodeStarSourceConnection [1] Source action provider in your pipeline's source stage. The AWS::CodeStarConnections::Connection resource [2] is also supported in CloudFormation. You may reference an existing Connection's ARN, or create a new one in CloudFormation. Existing Connections can be found here [0].
Here is an example template snippet:
Resources:
CodeStarConnection:
Type: 'AWS::CodeStarConnections::Connection'
Properties:
ConnectionName: MyGitHubConnection
ProviderType: GitHub
CodePipeline:
Type: 'AWS::CodePipeline::Pipeline'
Properties:
Stages:
- Name: Source
Actions:
- Name: SourceAction
ActionTypeId:
Category: Source
Owner: AWS
Version: 1
Provider: CodeStarSourceConnection
OutputArtifacts:
- Name: SourceArtifact
Configuration:
ConnectionArn: !Ref CodeStarConnection
BranchName: master
FullRepositoryId: username/repository
RunOrder: 1
... ...
Note: A connection created through CloudFormation is in PENDING status by default. You can make its status AVAILABLE by updating the connection in the console [3]. After the Connection being available, you may use your CodePipeline with the Github version 2 source action.
References:
[0] Connections - https://console.aws.amazon.com/codesuite/settings/connections
[1] CodeStarSourceConnection - https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html
[2] AWS::CodeStarConnections::Connection - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarconnections-connection.html
[3] Update a pending connection - https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-update.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.