Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c974b3d

Browse files
committedFeb 16, 2018
Added Jenkinsfile and Dockerfiles for automated builds and tests on all supported platforms.
Closes jgaa#41
1 parent bcaef76 commit c974b3d

File tree

5 files changed

+273
-0
lines changed

5 files changed

+273
-0
lines changed
 

‎ci/jenkins/Dockefile.debian-testing

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM debian:testing
2+
3+
MAINTAINER Jarle Aase <jgaa@jgaa.com>
4+
5+
# In case you need proxy
6+
RUN apt-get -q update &&\
7+
apt-get -y -q --no-install-recommends upgrade &&\
8+
apt-get -y -q install openssh-server g++ git \
9+
automake autoconf ruby ruby-dev rubygems build-essential \
10+
zlib1g-dev g++ cmake make libboost-all-dev libssl-dev \
11+
openjdk-8-jdk &&\
12+
gem install --no-ri --no-rdoc fpm &&\
13+
apt-get -y -q autoremove &&\
14+
apt-get -y -q clean
15+
16+
# Set user jenkins to the image
17+
RUN useradd -m -d /home/jenkins -s /bin/sh jenkins &&\
18+
echo "jenkins:jenkins" | chpasswd
19+
20+
# Standard SSH port
21+
EXPOSE 22
22+
23+
# Default command
24+
CMD ["/usr/sbin/sshd", "-D"]

‎ci/jenkins/Dockefile.ubuntu-xenial

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ubuntu:xenial
2+
3+
MAINTAINER Jarle Aase <jgaa@jgaa.com>
4+
5+
# In case you need proxy
6+
#RUN echo 'Acquire::http::Proxy "http://127.0.0.1:8080";' >> /etc/apt/apt.conf
7+
8+
RUN apt-get -q update &&\
9+
apt-get -y -q --no-install-recommends upgrade &&\
10+
apt-get -y -q install openssh-server g++ git \
11+
automake autoconf ruby ruby-dev rubygems build-essential \
12+
zlib1g-dev g++ cmake make libboost-all-dev libssl-dev \
13+
openjdk-8-jdk &&\
14+
gem install --no-ri --no-rdoc fpm &&\
15+
apt-get -y -q autoremove &&\
16+
apt-get -y -q clean
17+
18+
# Set user jenkins to the image
19+
RUN useradd -m -d /home/jenkins -s /bin/sh jenkins &&\
20+
echo "jenkins:jenkins" | chpasswd
21+
22+
# Standard SSH port
23+
EXPOSE 22
24+
25+
# Default command
26+
CMD ["/usr/sbin/sshd", "-D"]

‎ci/jenkins/Dockerfile.debian-stretch

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM debian:stretch
2+
3+
MAINTAINER Jarle Aase <jgaa@jgaa.com>
4+
5+
# In case you need proxy
6+
RUN apt-get -q update &&\
7+
apt-get -y -q --no-install-recommends upgrade &&\
8+
apt-get -y -q install openssh-server g++ git \
9+
automake autoconf ruby ruby-dev rubygems build-essential \
10+
zlib1g-dev g++ cmake make libboost-all-dev libssl-dev \
11+
openjdk-8-jdk &&\
12+
gem install --no-ri --no-rdoc fpm &&\
13+
apt-get -y -q autoremove &&\
14+
apt-get -y -q clean
15+
16+
# Set user jenkins to the image
17+
RUN useradd -m -d /home/jenkins -s /bin/sh jenkins &&\
18+
echo "jenkins:jenkins" | chpasswd
19+
20+
# Standard SSH port
21+
EXPOSE 22
22+
23+
# Default command
24+
CMD ["/usr/sbin/sshd", "-D"]

‎ci/jenkins/Dockerfile.fedora

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM fedora:27
2+
3+
MAINTAINER Jarle Aase <jgaa@jgaa.com>
4+
5+
RUN echo "root:password" | chpasswd
6+
RUN useradd jenkins
7+
RUN echo "jenkins:jenkins" | chpasswd
8+
9+
RUN dnf -y update &&\
10+
dnf -y install @development-tools git jre-openjdk zlib-devel openssl-devel boost-devel cmake gcc-c++ openssh-server
11+
12+
# expose the ssh port
13+
EXPOSE 22
14+
15+
# entrypoint by starting sshd
16+
CMD ["/usr/sbin/sshd", "-D"]
17+

‎ci/jenkins/Jenkinsfile.groovy

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
#!/usr/bin/env groovy
2+
3+
pipeline {
4+
agent { label 'master' }
5+
6+
environment {
7+
RESTC_CPP_VERSION = "0.9.1"
8+
9+
// It is not possible to get the current IP number when running in the sandbox, and
10+
// Jenkinsfiles always runs in the sandbox.
11+
// For simplicity, I just put it here (I already wastes 3 hours on this)
12+
RESTC_CPP_TEST_DOCKER_ADDRESS="10.201.0.11"
13+
}
14+
15+
stages {
16+
stage('Prepare') {
17+
steps {
18+
sh './create-and-run-containers.sh'
19+
sh 'docker ps'
20+
}
21+
}
22+
23+
stage('Build') {
24+
parallel {
25+
stage('Docker-build inside: ubuntu-xenial') {
26+
agent {
27+
dockerfile {
28+
filename 'Dockefile.ubuntu-xenial'
29+
dir 'ci/jenkins'
30+
label 'master'
31+
}
32+
}
33+
34+
steps {
35+
echo "Building on ubuntu-xenial-AMD64 in ${WORKSPACE}"
36+
checkout scm
37+
sh 'pwd; ls -la'
38+
sh 'rm -rf build'
39+
sh 'mkdir build'
40+
sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j2 && ctest --no-compress-output -T Test'
41+
}
42+
}
43+
44+
stage('Docker-build inside: debian-stretch') {
45+
agent {
46+
dockerfile {
47+
filename 'Dockerfile.debian-stretch'
48+
dir 'ci/jenkins'
49+
label 'master'
50+
}
51+
}
52+
53+
steps {
54+
echo "Building on debian-stretch-AMD64 in ${WORKSPACE}"
55+
checkout scm
56+
sh 'pwd; ls -la'
57+
sh 'rm -rf build'
58+
sh 'mkdir build'
59+
sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j2 && ctest --no-compress-output -T Test'
60+
}
61+
}
62+
63+
stage('Docker-build inside: debian-testing') {
64+
agent {
65+
dockerfile {
66+
filename 'Dockefile.debian-testing'
67+
dir 'ci/jenkins'
68+
label 'master'
69+
}
70+
}
71+
72+
steps {
73+
echo "Building on debian-testing-AMD64 in ${WORKSPACE}"
74+
checkout scm
75+
sh 'pwd; ls -la'
76+
sh 'rm -rf build'
77+
sh 'mkdir build'
78+
sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j2 && ctest --no-compress-output -T Test'
79+
}
80+
}
81+
82+
stage('macOS-build: ') {
83+
agent {label 'macos'}
84+
85+
environment {
86+
CPPFLAGS = "-I/usr/local/opt/openssl/include -I/usr/local/opt/zlib/include -I/usr/local/opt/boost/include/"
87+
LDFLAGS = "-L/usr/local/opt/openssl/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/boost/lib/"
88+
}
89+
90+
// Dependencies are installed with: brew install openssl boost zlib
91+
92+
steps {
93+
echo "Building on ubuntu-xenial-AMD64 in ${WORKSPACE}"
94+
checkout scm
95+
sh 'pwd; ls -la'
96+
sh 'rm -rf build'
97+
sh 'mkdir build'
98+
sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -DBOOST_LIBRARIES=/usr/local/opt/boost/lib -DBOOSTL_ROOT_DIR=/usr/local/opt/boost -DZLIB_INCLUDE_DIRS=/usr/local/opt/zlib/include/ -DZLIB_LIBRARIES=/usr/local/opt/zlib/lib/ .. && make -j4 && ctest --no-compress-output -T Test'
99+
}
100+
}
101+
102+
stage('Windows-MSVCx64') {
103+
104+
agent {label 'windows'}
105+
106+
steps {
107+
echo "Building on Windows in ${WORKSPACE}"
108+
checkout scm
109+
110+
bat script: '''
111+
112+
PATH=%PATH%;C:\\devel\\zlib-1.2.11\\Release;C:\\devel\\openssl\\lib-x64\\bin;C:\\local\\boost_1_64_0\\lib64-msvc-14.1
113+
rmdir /S /Q build
114+
mkdir build
115+
cd build
116+
cmake -DCMAKE_PREFIX_PATH=c:/devel/zlib-1.2.11;c:/devel/zlib-1.2.11/Release;c:/devel/openssl;c:/devel/boost_1_64_0 -G "Visual Studio 15 Win64" ..
117+
if %errorlevel% neq 0 exit /b %errorlevel%
118+
cmake --build . --config Release
119+
if %errorlevel% neq 0 exit /b %errorlevel%
120+
ctest -C Release
121+
if %errorlevel% neq 0 exit /b %errorlevel%
122+
123+
echo "Everything is OK"
124+
'''
125+
}
126+
}
127+
128+
stage('Windows-MSVCx64-cpp17') {
129+
130+
agent {label 'windows'}
131+
132+
steps {
133+
echo "Building on Windows in ${WORKSPACE}"
134+
checkout scm
135+
136+
bat script: '''
137+
138+
PATH=%PATH%;C:\\devel\\zlib-1.2.11\\Release;C:\\devel\\openssl\\lib-x64\\bin;C:\\local\\boost_1_64_0\\lib64-msvc-14.1
139+
rmdir /S /Q build
140+
mkdir build
141+
cd build
142+
cmake -DRESTC_CPP_USE_CPP17=ON -DCMAKE_PREFIX_PATH=c:/devel/zlib-1.2.11;c:/devel/zlib-1.2.11/Release;c:/devel/openssl;c:/devel/boost_1_64_0 -G "Visual Studio 15 Win64" ..
143+
if %errorlevel% neq 0 exit /b %errorlevel%
144+
cmake --build . --config Release
145+
if %errorlevel% neq 0 exit /b %errorlevel%
146+
ctest -C Release
147+
if %errorlevel% neq 0 exit /b %errorlevel%
148+
149+
echo "Everything is OK"
150+
'''
151+
}
152+
}
153+
154+
stage('Docker-build inside: Fedora') {
155+
agent {
156+
dockerfile {
157+
filename 'Dockerfile.fedora'
158+
dir 'ci/jenkins'
159+
label 'master'
160+
}
161+
}
162+
163+
steps {
164+
echo "Building on Fedora in ${WORKSPACE}"
165+
checkout scm
166+
sh 'pwd; ls -la'
167+
sh 'rm -rf build'
168+
sh 'mkdir build'
169+
sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j2 && ctest --no-compress-output -T Test'
170+
}
171+
}
172+
}
173+
}
174+
175+
stage('Clean-up') {
176+
steps {
177+
sh 'docker stop restc-cpp-squid restc-cpp-nginx restc-cpp-json'
178+
}
179+
}
180+
}
181+
}
182+

0 commit comments

Comments
 (0)
Please sign in to comment.