Skip to content

Commit 575186e

Browse files
authored
[CI] Enable basic setup with Jenkins over Docker. (#13)
* [CI] Update Jenkis file with basic setup * [CI] Enable Dockerfile with Jenkins
1 parent 7cc31ff commit 575186e

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-12
lines changed

Dockerfile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ARG NODE_VERSION=10.23.1
2+
FROM node:${NODE_VERSION} AS base
3+
4+
ENV HOME '.'
5+
RUN apt-get update && \
6+
apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
7+
libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
8+
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
9+
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
10+
libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget openjdk-8-jre && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
RUN curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
14+
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
15+
&& apt-get update \
16+
&& apt-get install -y rsync jq bsdtar google-chrome-stable \
17+
--no-install-recommends \
18+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
19+
20+
RUN LATEST_VAULT_RELEASE=$(curl -s https://api.github.com/repos/hashicorp/vault/tags | jq --raw-output .[0].name[1:]) \
21+
&& curl -L https://releases.hashicorp.com/vault/${LATEST_VAULT_RELEASE}/vault_${LATEST_VAULT_RELEASE}_linux_amd64.zip -o vault.zip \
22+
&& unzip vault.zip \
23+
&& rm vault.zip \
24+
&& chmod +x vault \
25+
&& mv vault /usr/local/bin/vault
26+
27+
RUN apt-get update && apt-get install -y \
28+
python-pip
29+
RUN pip install awscli
30+
31+
RUN groupadd -r kibana && useradd -r -g kibana kibana && mkdir /home/kibana && chown kibana:kibana /home/kibana
32+
33+
USER kibana

Jenkinsfile

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
node {
22
label 'website'
3+
def scmVars = checkout scm
34
sh "env"
4-
echo "BRANCH: ${scmVars.GIT_BRANCH}, COMMIT: ${scmVars.GIT_COMMIT}"
5-
stage('bootstrap') {
6-
sh 'yarn kbn bootstrap'
5+
def imageName = "test-image:${env.BUILD_ID}"
6+
def testImage
7+
stage('Build container image') {
8+
sh 'ls -l'
9+
testImage = docker.build imageName
710
}
8-
stage('unit tests') {
9-
sh 'yarn test:jest'
10-
}
11-
stage('integration tests') {
12-
sh 'yarn test:jest_integration'
13-
sh 'yarn test:mocha'
14-
}
15-
stage('build'){
16-
sh 'yarn build --oss --skip-os-packages'
11+
testImage.inside {
12+
try {
13+
stage('bootstrap') {
14+
sh 'yarn kbn bootstrap'
15+
}
16+
stage('unit tests') {
17+
sh 'yarn test:jest -u --ci --verbose --maxWorkers=5'
18+
}
19+
stage('integration tests') {
20+
sh 'yarn test:jest_integration -u --ci'
21+
sh 'yarn test:mocha'
22+
}
23+
} catch (e) {
24+
echo 'This will run only if failed'
25+
currentBuild.result = 'FAILURE'
26+
// Since we're catching the exception in order to report on it,
27+
// we need to re-throw it, to ensure that the build is marked as failed
28+
throw e
29+
}
1730
}
1831
}

0 commit comments

Comments
 (0)