Skip to content

Commit d16f350

Browse files
authored
Support publishing a snapshot build for each commit to main (#3050)
* Support daily snapshots Signed-off-by: Adrien Mannocci <[email protected]> * Add suggestions Signed-off-by: Adrien Mannocci <[email protected]>
1 parent 62c8f67 commit d16f350

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

.ci/Jenkinsfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,39 @@ pipeline {
250250
}
251251
}
252252
}
253+
254+
/**
255+
Publish a snapshot. A "snapshot" is a packaging of the latest *unreleased* APM agent,
256+
published to a known GCS bucket for use in edge demo/test environments.
257+
*/
258+
stage('Publish snapshot') {
259+
options { skipDefaultCheckout() }
260+
environment {
261+
BUCKET_NAME = 'oblt-artifacts'
262+
DOCKER_REGISTRY = 'docker.elastic.co'
263+
DOCKER_REGISTRY_SECRET = 'secret/observability-team/ci/docker-registry/prod'
264+
GCS_ACCOUNT_SECRET = 'secret/observability-team/ci/snapshoty'
265+
}
266+
when { branch 'main' }
267+
steps {
268+
withGithubNotify(context: 'Publish snapshot packages') {
269+
deleteDir()
270+
unstash name: 'source'
271+
withNodeJSEnv(version: env.BUILD_NODE_VERSION) {
272+
dir(env.BASE_DIR) {
273+
sh(label: 'package snapshot', script: 'npm run package:snapshot')
274+
snapshoty(
275+
bucket: env.BUCKET_NAME,
276+
gcsAccountSecret: env.GCS_ACCOUNT_SECRET,
277+
dockerRegistry: env.DOCKER_REGISTRY,
278+
dockerSecret: env.DOCKER_REGISTRY_SECRET
279+
)
280+
}
281+
}
282+
}
283+
}
284+
}
285+
253286
stage('Release') {
254287
options { skipDefaultCheckout() }
255288
when {

.ci/snapshoty.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
3+
# Version of configuration to use
4+
version: '1.0'
5+
6+
# You can define a Google Cloud Account to use
7+
account:
8+
# Project id of the service account
9+
project: '${GCS_PROJECT}'
10+
# Private key id of the service account
11+
private_key_id: '${GCS_PRIVATE_KEY_ID}'
12+
# Private key of the service account
13+
private_key: '${GCS_PRIVATE_KEY}'
14+
# Email of the service account
15+
client_email: '${GCS_CLIENT_EMAIL}'
16+
# URI token
17+
token_uri: 'https://oauth2.googleapis.com/token'
18+
19+
# List of artifacts
20+
artifacts:
21+
# Path to use for artifacts discovery
22+
- path: './build/snapshot'
23+
# Files pattern to match
24+
files_pattern: 'elastic-apm-node-(?P<app_version>\d+\.\d+\.\d+)\.tgz'
25+
# File layout on GCS bucket
26+
output_pattern: '{project}/{jenkins_branch_name}/elastic-apm-node-{app_version}-{jenkins_git_commit_short}.tgz'
27+
# List of metadata processors to use.
28+
metadata:
29+
# Define static custom metadata
30+
- name: 'custom'
31+
data:
32+
project: 'apm-agent-nodejs'
33+
# Add git metadata
34+
- name: 'git'
35+
# Add jenkins metadata
36+
- name: 'jenkins'

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"docker:start": "docker-compose -f ./test/docker-compose.yml up -d",
2929
"docker:stop": "docker-compose -f ./test/docker-compose.yml down",
3030
"docker:clean": "./test/script/docker/cleanup.sh",
31-
"docker:dev": "docker-compose -f ./dev-utils/docker-compose.yml run --workdir=/agent nodejs-agent"
31+
"docker:dev": "docker-compose -f ./dev-utils/docker-compose.yml run --workdir=/agent nodejs-agent",
32+
"package:snapshot": "rm -rf ./build/snapshot && mkdir -p ./build/snapshot && npm pack --pack-destination ./build/snapshot"
3233
},
3334
"directories": {
3435
"test": "test"

0 commit comments

Comments
 (0)