|
| 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