I'm trying to set up a pipeline for CI for a project, which is heavily using AWS stack. We already have Bitbucket and Jenkins servers, so ideally I would like to avoid the creation of infrastructure components with duplicating functionality.
What I would like to get: Jenkins executes unit/integration tests, builds artifacts and then triggers Codepipeline, which deploys CF stacks and performs end-to-end tests. I was able to create a primitive pipeline with a combination of AWS steps plugin, S3 and Codepipeline.
Jenkinsfile:
#!groovy
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building..'
sh "mvn clean package"
}
}
stage('S3upload') {
steps {
withAWS(region:'us-east-1',credentials:'JENKINS') {
s3Upload(bucket: 'somebucket', workingDir:'target', includePathPattern:'some.jar');
}
}
}
}
}
Codepipeline:
{
"pipeline": {
"name": "SomePipeline",
<...>
,
"stages": [
{
"name": "Source",
"actions": [
{
"name": "Source",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "S3",
"version": "1"
},
"runOrder": 1,
"configuration": {
"PollForSourceChanges": "false",
"S3Bucket": "somebucket",
"S3ObjectKey": "some.jar"
},
"outputArtifacts": [
{
"name": "SourceArtifact"
}
],
"inputArtifacts": [],
"region": "us-east-1"
}
]
},
{
"name": "DeployCognitoStack",
"actions": [
{
"name": "DeployCognitoStack",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CloudFormation",
"version": "1"
},
"runOrder": 1,
"configuration": {
"ActionMode": "CREATE_UPDATE",
"Capabilities": "CAPABILITY_IAM,CAPABILITY_AUTO_EXPAND",
"RoleArn": "arn:aws:iam::*:role/CloudFormationRole",
"StackName": "cognitostacktest",
"TemplatePath": "SourceArtifact::cognito-stack.yaml"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "SourceArtifact"
}
],
"region": "us-east-1"
}
]
},
{
"name": "DeployLambdaStack",
"actions": [
{
"name": "DeployLambdaStack",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CloudFormation",
"version": "1"
},
"runOrder": 1,
"configuration": {
"ActionMode": "CREATE_UPDATE",
"Capabilities": "CAPABILITY_NAMED_IAM,CAPABILITY_AUTO_EXPAND",
"RoleArn": "arn:aws:iam::*:role/CloudFormationRole",
"StackName": "lambdatest",
"TemplatePath": "SourceArtifact::lambda-stack.yaml"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "SourceArtifact"
}
],
"region": "us-east-1"
}
]
},
<here should be test stage>
],
"version": 5
}
}
What I do not like is that I need to look separately to the results of Jenkins job execution and to results of Codepipeline execution. I would prefer to see everything in Jenkins.
Which options do I see:
Forget about Codepipeline, use only commands from AWS Steps plugin to deploy test stacks and execute end-to-end tests by scripts.
Follow AWS four-steps pipeline tutorial. If I understand it correctly, this solution will require active polling of SCM and pulling code to AWS.
Am I missing something?