Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(jenkins): enable pipeline #8

Merged
merged 6 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env groovy

@Library('apm@current') _

pipeline {
agent { label 'linux && immutable' }
environment {
REPO = 'apm-agent-php'
BASE_DIR = "src/go.elastic.co/apm/${env.REPO}"
NOTIFY_TO = credentials('notify-to')
JOB_GCS_BUCKET = credentials('gcs-bucket')
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
timestamps()
ansiColor('xterm')
disableResume()
durabilityHint('PERFORMANCE_OPTIMIZED')
rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
quietPeriod(10)
}
triggers {
issueCommentTrigger('(?i).*jenkins\\W+run\\W+(?:the\\W+)?tests(?:\\W+please)?.*')
}
stages {
stage('Checkout') {
options { skipDefaultCheckout() }
steps {
deleteDir()
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
}
}
stage('Build') {
options { skipDefaultCheckout() }
steps {
withGithubNotify(context: 'Build') {
deleteDir()
unstash 'source'
dir("${BASE_DIR}"){
sh script: 'docker build --tag apm-agent-php .', label: 'prepare docker image'
sh script: 'docker run --rm -t -v $(pwd):/app apm-agent-php', label: 'run docker container'
}
}
}
}
}
post {
cleanup {
notifyBuildResult()
}
}
}
5 changes: 5 additions & 0 deletions .ci/jobs/apm-agent-php-mbp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- job:
name: apm-agent-php/apm-agent-php-mbp
display-name: APM Agent PHP
description: APM Agent PHP
4 changes: 4 additions & 0 deletions .ci/jobs/apm-agent-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- job:
name: apm-agent-php
project-type: folder
57 changes: 57 additions & 0 deletions .ci/jobs/defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

##### GLOBAL METADATA

- meta:
cluster: apm-ci

##### JOB DEFAULTS

- job:
view: APM-CI
project-type: multibranch
logrotate:
numToKeep: 100
concurrent: true
node: linux
script-path: .ci/Jenkinsfile
scm:
- github:
branch-discovery: no-pr
discover-pr-forks-strategy: merge-current
discover-pr-forks-trust: permission
discover-pr-origin: merge-current
discover-tags: true
notification-context: 'apm-ci'
repo: apm-agent-php
repo-owner: elastic
credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
ssh-checkout:
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
build-strategies:
- tags:
ignore-tags-older-than: -1
ignore-tags-newer-than: -1
- regular-branches: true
- change-request:
ignore-target-only-changes: false
clean:
after: true
before: true
prune: true
shallow-clone: true
depth: 3
do-not-fetch-tags: true
submodule:
disable: false
recursive: true
parent-credentials: true
timeout: 100
timeout: '15'
use-author: true
wipe-workspace: 'True'
periodic-folder-trigger: 1d
prune-dead-branches: true
publishers:
- email:
recipients: infra-root+build@elastic.co
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.ci
.dockerignore
.git
.gitignore
docker
docs
Dockerfile
README.md
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM wordpress:php7.3-fpm-alpine

RUN apk --no-cache add build-base autoconf curl-dev

WORKDIR /app/src/ext

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to copy the extension to /app/src/ext first in order compile "it" on L:7

COPY src/ext /app/src/ext

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required since this particular docker image is only for the environmental requirements.
The docker container should mount the volume and therefore the CMD directive will run those commands using the mounted volume.

CMD phpize \
&& ./configure --enable-elasticapm \
&& make clean \
&& make \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add && make test \

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure whether either make or make install might call the command make test as a dependent goal. I'll put it explicitly, now, and archive the test output

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided to change the approach:

The reason is to help to categorize those commands in stages in the pipeline and visualise them easily in the CI.

&& make install