Add metadata to artifacts step in buildspec

Viewed 188

I have an existing buildspec file to be used in a code pipeline. It's using gradle to generate the JAR file. In codebuild, the artifacts are zipped up to be placed into S3.

I saw an article that says if we provide a metadata called "codepipeline-artifact-revision-summary" it will provide a more helpful output in the code pipeline display.

The buildspec reference syntax doesn't seem to provide this option.

How should I get the metadata in the artifacts stage?

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto8
    commands:
      - echo Entered the install phase...
      - apt-key adv --refresh-keys --keyserver hkp://keyserver.ubuntu.com:80
      - apt-get update -y
      - wget https://services.gradle.org/distributions/gradle-5.0-bin.zip -P /tmp
      - mkdir /opt/gradle
      - unzip -d /opt/gradle /tmp/gradle-*.zip

  build:
    commands:
      - echo Build commands started on `date`
      - /opt/gradle/gradle-5.0/bin/gradle clean build bootJar -x test -Pprofile=prod --refresh-dependencies
      - echo Build commands completed on `date`
  post_build:
    commands:
      - echo Post build commands started on `date`
      - pwd
      - echo Post build commands completed on `date`

artifacts:
  files:
    - appspec.yml
    - build/libs/*.jar
    - scripts/**
  discard-paths: yes

cache:
  paths:
    - '/root/.gradle/caches/**/*'
1 Answers

Take another look at the article you linked to. Seems it's nothing to do with the buildspec file. Instead it's an extra file that the article author has generated from the Bitbucket pipeline that also writes their source to S3.

The key would be creating that file in the S3 bucket where the pipeline gets its source. If you can create that, then the improved output should work.

Related