Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom version label with aws code pipeline

I'm using AWS CodePipeline with CodeBuild to build and deploy my application to ElasticBeanstalk.

CodePipeline generates version names like this: code-pipeline-1122334455667-MyApp-1ac31f7c-1343-471x-a7e8-46b24f1785a

Is it possible to customize these labels?

like image 407
RoddyRott Avatar asked Nov 12 '18 14:11

RoddyRott


People also ask

How do I change my AWS CodePipeline name?

To edit a pipelineSign in to the AWS Management Console and open the CodePipeline console at http://console.aws.amazon.com/codesuite/codepipeline/home . The names of all pipelines associated with your AWS account are displayed. In Name, choose the name of the pipeline you want to edit.

How do you edit AWS pipeline?

You can edit a pipeline using the AWS Management Console. On the List Pipelines page, check the Pipeline ID and Name columns for your pipeline, and then choose your Pipeline ID. Then choose Edit Pipeline to display the pipeline Architect page.

What is tagging in pipeline?

Tags are case-sensitive key-value pairs that consist of a key and an optional value, both defined by the user. You can apply up to ten tags to each pipeline. Tag keys must be unique for each pipeline.


1 Answers

You can set a version label if you use an AWS CodeBuild action provider instead of an AWS ElasticBeanstalk deploy action provider.

CodeBuild has the ability to run AWS CLI commands in the buildspec, which you can use to

  1. upload your build artifact to S3 (documentation)
  2. create a version in Elastic Beanstalk (documentation)
  3. deploy the version (documentation)

Below is an example buildspec uploading an artifact with a custom label, file name, and description.

version: 0.2

phases:
  build:
    commands:
      - mvn clean package
      - export POM_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
      - export JAR_NAME='application-'$POM_VERSION'.jar'
      - export EB_VERSION=$POM_VERSION'-'$(date +%s)
      - aws s3 cp target/application.jar s3://bucket-name/$JAR_NAME
      - aws elasticbeanstalk create-application-version --application-name "Application Name" --version-label "$EB_VERSION" --description "$CommitMessage" --source-bundle S3Bucket=bucket-name,S3Key=$JAR_NAME
      - aws elasticbeanstalk update-environment --application-name "Application Name" --version-label "$EB_VERSION" --environment-name "EnvironmentName"

Notes:

  • $CommitMessage is coming in from CodePipeline as an environment variable.
  • The date is appended to the version name to avoid naming collisions.
like image 175
Benjamin Bublitz Avatar answered Oct 11 '22 08:10

Benjamin Bublitz