Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 66f4394

Browse files
leJsboureausrobert-myscript
authored andcommitted
fix(Jenkinsfile) update agent label from master to docker
1 parent 50e4126 commit 66f4394

File tree

6 files changed

+100
-32
lines changed

6 files changed

+100
-32
lines changed

Jenkinsfile

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,93 @@
1+
2+
def debianBuildDockerImage
3+
String dockerArgs = '-v /var/run/docker.sock:/var/run/docker.sock --userns host --privileged -v $HOME:$HOME -e "HOME=${HOME}'
4+
15
pipeline {
2-
agent {label 'master'}
6+
agent { label "docker" }
37
options { disableConcurrentBuilds() }
48
environment {
59
PROJECTNAME = "iink-js ${env.BRANCH_NAME}"
610
PROJECTHOME = '/tmp/iink-js'
7-
PROJECT_DIR= "${WORKSPACE.replace('/var/jenkins_home/workspace','/dockervolumes/cloud/master/jenkins/workspace')}"
11+
PROJECT_DIR = "${WORKSPACE.replace('/var/jenkins_home/workspace','/dockervolumes/cloud/master/jenkins/workspace')}"
812
APPLICATION_KEY = credentials('APPLICATION_KEY')
913
HMAC_KEY = credentials('HMAC_KEY')
10-
MAKE_ARGS=" PROJECT_DIR=${env.PROJECT_DIR} HOME=${env.PROJECTHOME} BUILDID=${env.BUILD_NUMBER} DEV_APPLICATIONKEY=${env.APPLICATION_KEY} DEV_HMACKEY=${env.HMAC_KEY} "
14+
MAKE_ARGS =" PROJECT_DIR=${env.PROJECT_DIR} HOME=${env.PROJECTHOME} BUILDID=${env.BUILD_NUMBER} DEV_APPLICATIONKEY=${env.APPLICATION_KEY} DEV_HMACKEY=${env.HMAC_KEY} "
1115
}
1216

1317
stages {
1418

15-
stage ('purge'){
19+
stage('Build docker builder') {
1620
steps {
17-
sh "make ${env.MAKE_ARGS} purge"
21+
script {
22+
debianBuildDockerImage = docker.build("iink-js.debian-builder:${env.BUILD_ID}", '-f ./docker/builder/Dockerfile ./')
23+
}
1824
}
1925
}
2026

21-
stage ('prepare'){
27+
stage ('purge'){
2228
steps {
23-
sh "make ${env.MAKE_ARGS} prepare"
29+
script {
30+
debianBuildDockerImage.inside(dockerArgs) {
31+
sh "make ${env.MAKE_ARGS} purge"
32+
}
33+
}
2434
}
2535
}
2636

27-
stage ('docker'){
37+
stage ('prepare'){
2838
steps {
29-
sh "make ${env.MAKE_ARGS} docker"
39+
script {
40+
debianBuildDockerImage.inside(dockerArgs) {
41+
sh "make ${env.MAKE_ARGS} prepare"
42+
sh "make ${env.MAKE_ARGS} docker-wait-tcp"
43+
}
44+
}
3045
}
3146
}
3247

3348
stage ('init_examples'){
3449
steps {
35-
sh "make ${env.MAKE_ARGS} init_examples"
50+
script {
51+
debianBuildDockerImage.inside(dockerArgs) {
52+
sh "make ${env.MAKE_ARGS} docker-examples init_examples"
53+
}
54+
}
3655
}
3756
}
3857

39-
stage('test browser') {
58+
stage('test browser with legacy server') {
4059

4160
failFast false
4261

4362
parallel {
44-
63+
4564
stage ('test-chromium'){
4665
steps {
47-
sh "BROWSER=chromium make ${env.MAKE_ARGS} test-e2e"
66+
script {
67+
debianBuildDockerImage.inside(dockerArgs) {
68+
sh "BROWSER=chromium make ${env.MAKE_ARGS} test-e2e"
69+
}
70+
}
4871
}
4972
}
5073

5174
stage ('test-webkit'){
5275
steps {
53-
sh "BROWSER=webkit make ${env.MAKE_ARGS} test-e2e"
76+
script {
77+
debianBuildDockerImage.inside(dockerArgs) {
78+
sh "BROWSER=webkit make ${env.MAKE_ARGS} test-e2e"
79+
}
80+
}
5481
}
5582
}
5683

5784
stage ('test-firefox'){
5885
steps {
59-
sh "BROWSER=firefox make ${env.MAKE_ARGS} test-e2e"
86+
script {
87+
debianBuildDockerImage.inside(dockerArgs) {
88+
sh "BROWSER=firefox make ${env.MAKE_ARGS} test-e2e"
89+
}
90+
}
6091
}
6192
}
6293
}
@@ -65,7 +96,11 @@ pipeline {
6596

6697
stage ('audit'){
6798
steps {
68-
sh "npm audit --production"
99+
script {
100+
debianBuildDockerImage.inside(dockerArgs) {
101+
sh "npm audit --production"
102+
}
103+
}
69104
}
70105
}
71106
}

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ build: clean ## Building the dist files from sources.
2020
docs: ## Building the doc files from sources.
2121
@npm run docs
2222

23-
docker: build ## Build the docker image containing last version of myscript-js and examples.
23+
docker-wait-tcp:
24+
@cd docker/wait-tcp/ && docker build -t $(WAITTCP_DOCKERREPOSITORY) .
25+
26+
docker-examples: build ## Build the docker image containing last version of myscript-js and examples.
2427
@rm -rf docker/examples/delivery/
2528
@mkdir -p docker/examples/delivery
2629
@cp -R dist docker/examples/delivery/
@@ -29,13 +32,14 @@ docker: build ## Build the docker image containing last version of myscript-js a
2932
@cd docker/examples/ && \
3033
docker build \
3134
--build-arg applicationkey=${DEV_APPLICATIONKEY} \
32-
--build-arg hmackey=${DEV_HMACKEY} $(DOCKER_PARAMETERS) -t $(EXAMPLES_DOCKERREPOSITORY) .
35+
--build-arg hmackey=${DEV_HMACKEY} \
36+
-t $(EXAMPLES_DOCKERREPOSITORY) .
3337

3438
killdocker:
3539
@docker ps -a | grep "iinkjs-$(DOCKERTAG)-$(BUILDENV)-" | awk '{print $$1}' | xargs -r docker rm -f 2>/dev/null 1>/dev/null || true
3640

3741

38-
local-test-e2e: init_examples
42+
local-test-e2e: docker-examples init_examples
3943
@$(MAKE) BROWSER=$(BROWSER) test-e2e
4044

4145
test-e2e:
@@ -53,9 +57,7 @@ test-e2e:
5357
--name "playwright-$(BROWSER)-$(BUILDID)" mcr.microsoft.com/playwright:v1.16.0 \
5458
yarn test:e2e
5559

56-
dev-all: dev-examples ## Launch all the requirements for launching tests.
57-
58-
dev-examples: init_examples ## Launch a local nginx server to ease development.
60+
dev-test: docker-examples init_examples ## Launch all the requirements for launching tests
5961

6062
_launch_examples:
6163
@echo "Starting examples container!"
@@ -67,13 +69,15 @@ _launch_examples:
6769
-e "HMACKEY=$(DEV_HMACKEY)" \
6870
$(DOCKER_EXAMPLES_PARAMETERS) \
6971
--name $(TEST_DOCKER_EXAMPLES_INSTANCE_NAME) $(EXAMPLES_DOCKERREPOSITORY)
72+
7073
_check_examples:
7174
@docker run --rm \
7275
--link $(TEST_DOCKER_EXAMPLES_INSTANCE_NAME):WAITHOST \
7376
-e "WAIT_PORT=$(EXAMPLES_LISTEN_PORT)" \
7477
-e "WAIT_SERVICE=Test examples" \
7578
$(WAITTCP_DOCKERREPOSITORY)
7679
@echo "Examples started!"
80+
7781
init_examples: _launch_examples _check_examples
7882

7983
help: ## This help.

Makefile.inc

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ REGISTRY = registry.corp.myscript.com:5000
2929
DOC_DOCKERREPOSITORY = $(REGISTRY)/iinkjs-docs:$(DOCKERTAG)
3030
EXAMPLES_DOCKERREPOSITORY = $(REGISTRY)/iinkjs-examples:$(DOCKERTAG)
3131

32-
CONFIGURATION_DOCKERTAG := master
33-
MOCHA_DOCKERREPOSITORY = $(REGISTRY)/myscript-webcomponents-mocha:$(CONFIGURATION_DOCKERTAG)
34-
WAITTCP_DOCKERREPOSITORY = $(REGISTRY)/myscript-webcomponents-wait-tcp:$(CONFIGURATION_DOCKERTAG)
32+
CONFIGURATION_DOCKERTAG := 1.0.0
33+
MOCHA_DOCKERREPOSITORY = $(REGISTRY)/iink-js-mocha:$(CONFIGURATION_DOCKERTAG)
34+
WAITTCP_DOCKERREPOSITORY = $(REGISTRY)/iink-js-wait-tcp:$(CONFIGURATION_DOCKERTAG)
3535

3636
BUILDENV := test
3737
TEST_DOCKER_NAME_PREFIX := iinkjs-$(DOCKERTAG)-$(BUILDENV)-$(BUILDID)
@@ -54,13 +54,6 @@ ifeq ($(IINKAPILOCAL),true)
5454
APISCHEME := http
5555
endif
5656

57-
58-
ifeq ($(OFFLINE),true)
59-
NPM_PARAMETERS := --cache-min 9999999
60-
else
61-
DOCKER_PARAMETERS := --pull
62-
endif
63-
6457
ifeq ($(DEVLOCAL),true)
6558
DOCKER_EXAMPLES_PARAMETERS := --net=host --userns=host
6659
EXAMPLES_LISTEN_PORT := 8080

docker/builder/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM debian:bullseye-slim
2+
ENV DEBIAN_FRONTEND noninteractive
3+
RUN apt update -yyq;
4+
RUN apt install make npm yarn git curl -yyq
5+
RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh

docker/wait-tcp/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM debian:buster-slim
2+
ENV DEBIAN_FRONTEND noninteractive
3+
4+
RUN apt update -yy;apt install -yy curl jq netcat-openbsd;rm -rf /var/lib/apt/* /var/cache/apt/*
5+
6+
ENV WAIT_SERVICE "Undef"
7+
ENV WAIT_PORT 80
8+
ENV WAIT_HOST WAITHOST
9+
ENV TIMEOUT 90
10+
ENV DEBUG false
11+
ADD /entrypoint.sh /entrypoint.sh
12+
13+
ENTRYPOINT ["/entrypoint.sh"]

docker/wait-tcp/entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
if [ ${DEBUG} != "false" ]; then
4+
set -xve
5+
fi
6+
7+
echo -n " => Waiting for ${WAIT_SERVICE} on tcp Port ${WAIT_PORT}"
8+
CPT=0
9+
while ! nc -z -w 1 ${WAIT_HOST} ${WAIT_PORT}; do
10+
((CPT++))
11+
if [ ${CPT} -gt ${TIMEOUT} ]; then
12+
echo " Timeout!"
13+
exit 1
14+
fi;
15+
sleep 1
16+
echo -n .
17+
done
18+
echo " Found!"

0 commit comments

Comments
 (0)