Skip to content

Commit

Permalink
Decouple lambda layer release from buildkite build (#3251)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKunz authored Jul 20, 2023
1 parent e50720c commit 2b73f49
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .ci/publish-aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ ALL_AWS_REGIONS=$(aws ec2 describe-regions --output json --no-cli-pager | jq -r
rm -rf "${AWS_FOLDER}"
mkdir -p "${AWS_FOLDER}"

zip_file="./elastic-apm-agent/target/${FULL_LAYER_NAME}.zip"
zip_file="./apm-agent-lambda-layer/target/${FULL_LAYER_NAME}.zip"

mv ./elastic-apm-agent/target/elastic-apm-java-aws-lambda-layer-*.zip "${zip_file}"
mv ./apm-agent-lambda-layer/target/elastic-apm-java-aws-lambda-layer-*.zip "${zip_file}"

for region in $ALL_AWS_REGIONS; do
echo "Publish ${FULL_LAYER_NAME} in ${region}"
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ jobs:
pipelineVersion: ${{ env.TAG_NAME }}
waitFor: true
printBuildLogs: false
artifactName: lambda-zip
artifactPath: "elastic-apm-agent/target/elastic-apm-java-aws-lambda-layer-*.zip"
artifactIfNoFilesFound: error
# The action fails with .github/actions/buildkite/run.sh: line 24: 3: parameter missing.
# Which is an unexpected bug.
# Adding a random buildEnvVar to circumvent the behaviour.
Expand Down Expand Up @@ -220,10 +217,14 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ env.TAG_NAME }}
- uses: actions/download-artifact@v3
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
name: lambda-zip
path: elastic-apm-agent/target
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: 'maven'
- name: Build Lambda-layer zip using agent from maven-central
run: ./mvnw dependency:purge-local-repository package -pl apm-agent-lambda-layer
- uses: hashicorp/[email protected]
with:
url: ${{ secrets.VAULT_ADDR }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static Path getPathToJavaagent(Variant agentBuild) {
}

public static Path getPathToAwsLambdaLayer() {
return getArtifactPath(Path.of("elastic-apm-agent"), "elastic-apm-java-aws-lambda-layer", "", ".zip");
return getArtifactPath(Path.of("apm-agent-lambda-layer"), "elastic-apm-java-aws-lambda-layer", "", ".zip");
}


Expand Down
104 changes: 104 additions & 0 deletions apm-agent-lambda-layer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>apm-agent-parent</artifactId>
<groupId>co.elastic.apm</groupId>
<version>1.40.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apm-agent-lambda-layer</artifactId>
<name>${project.groupId}:${project.artifactId}</name>

<properties>
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
<apm-agent-parent.base.dir>${project.basedir}/..</apm-agent-parent.base.dir>
</properties>

<dependencies>
<!-- This dependency listing is required so that running
./mvnw dependency:purge-local-repository package -pl apm-agent-lambda-layer
in the parent project forces a redownload of the agent artifact from maven central.
-->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elastic-apm-agent</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>elastic-apm-agent</artifactId>
<destFileName>elastic-apm-agent.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/aws-lambda</outputDirectory>
<resources>
<resource>
<directory>src/main/assembly</directory>
<filtering>true</filtering>
<includes>
<include>elastic-apm-handler</include>
</includes>
</resource>
</resources>
<delimiters>
<delimiter>[[*]]</delimiter>
</delimiters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/aws-lambda-layer.xml</descriptor>
</descriptors>
<finalName>elastic-apm-java-aws-lambda-layer-${project.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</fileSets>
<files>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
<source>${project.build.directory}/elastic-apm-agent.jar</source>
<outputDirectory>/</outputDirectory>
<destName>elastic-apm-agent.jar</destName>
</file>
Expand All @@ -23,4 +23,4 @@
<outputDirectory>/</outputDirectory>
</file>
</files>
</assembly>
</assembly>
45 changes: 0 additions & 45 deletions elastic-apm-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,51 +284,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/aws-lambda</outputDirectory>
<resources>
<resource>
<directory>src/main/assembly</directory>
<filtering>true</filtering>
<includes>
<include>elastic-apm-handler</include>
</includes>
</resource>
</resources>
<delimiters>
<delimiter>[[*]]</delimiter>
</delimiters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/aws-lambda-layer.xml</descriptor>
</descriptors>
<finalName>elastic-apm-java-aws-lambda-layer-${project.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<modules>
<module>apm-agent-core</module>
<module>elastic-apm-agent</module>
<module>apm-agent-lambda-layer</module>
<module>elastic-apm-agent-premain</module>
<module>elastic-apm-agent-java8</module>
<module>apm-agent-benchmarks</module>
Expand Down

0 comments on commit 2b73f49

Please sign in to comment.