1if (env.BRANCH_NAME == "master") { 2 properties([pipelineTriggers([cron('@daily')])]) 3} 4 5def configs = [ 6 [ 7 label: 'windows', 8 toxenvs: ['py27', 'py34', 'py35', 'py36', 'py37'], 9 ], 10 [ 11 label: 'windows64', 12 toxenvs: ['py27', 'py34', 'py35', 'py36', 'py37'], 13 ], 14 [ 15 label: 'sierra', 16 toxenvs: ['py27', 'py36'], 17 ], 18 [ 19 label: 'yosemite', 20 toxenvs: ['py27'], 21 ], 22 [ 23 label: 'docker', 24 imageName: 'pyca/cryptography-runner-sid', 25 toxenvs: ['docs'], 26 artifacts: 'cryptography/docs/_build/html/**', 27 artifactExcludes: '**/*.doctree', 28 ], 29] 30 31def checkout_git(label) { 32 retry(3) { 33 def script = "" 34 if (env.BRANCH_NAME.startsWith('PR-')) { 35 script = """ 36 git clone --depth=1 https://github.com/pyca/cryptography 37 cd cryptography 38 git fetch origin +refs/pull/${env.CHANGE_ID}/merge: 39 git checkout -qf FETCH_HEAD 40 """ 41 if (label.contains("windows")) { 42 bat script 43 } else { 44 sh """#!/bin/sh 45 set -xe 46 ${script} 47 """ 48 } 49 } else { 50 checkout([ 51 $class: 'GitSCM', 52 branches: [[name: "*/${env.BRANCH_NAME}"]], 53 doGenerateSubmoduleConfigurations: false, 54 extensions: [[ 55 $class: 'RelativeTargetDirectory', 56 relativeTargetDir: 'cryptography' 57 ]], 58 submoduleCfg: [], 59 userRemoteConfigs: [[ 60 'url': 'https://github.com/pyca/cryptography' 61 ]] 62 ]) 63 } 64 } 65 if (label.contains("windows")) { 66 bat """ 67 cd cryptography 68 git rev-parse HEAD 69 """ 70 } else { 71 sh """ 72 cd cryptography 73 git rev-parse HEAD 74 """ 75 } 76} 77def build(toxenv, label, imageName, artifacts, artifactExcludes) { 78 try { 79 timeout(time: 30, unit: 'MINUTES') { 80 81 checkout_git(label) 82 checkout([ 83 $class: 'GitSCM', 84 extensions: [[ 85 $class: 'RelativeTargetDirectory', 86 relativeTargetDir: 'wycheproof', 87 ]], 88 userRemoteConfigs: [[ 89 'url': 'https://github.com/google/wycheproof', 90 ]] 91 ]) 92 93 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) { 94 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) { 95 if (label.contains("windows")) { 96 def pythonPath = [ 97 py27: "C:\\Python27\\python.exe", 98 py34: "C:\\Python34\\python.exe", 99 py35: "C:\\Python35\\python.exe", 100 py36: "C:\\Python36\\python.exe", 101 py37: "C:\\Python37\\python.exe" 102 ] 103 if (toxenv == "py35" || toxenv == "py36" || toxenv == "py37") { 104 opensslPaths = [ 105 "windows": [ 106 "include": "C:\\OpenSSL-Win32-2015\\include", 107 "lib": "C:\\OpenSSL-Win32-2015\\lib" 108 ], 109 "windows64": [ 110 "include": "C:\\OpenSSL-Win64-2015\\include", 111 "lib": "C:\\OpenSSL-Win64-2015\\lib" 112 ] 113 ] 114 } else { 115 opensslPaths = [ 116 "windows": [ 117 "include": "C:\\OpenSSL-Win32-2010\\include", 118 "lib": "C:\\OpenSSL-Win32-2010\\lib" 119 ], 120 "windows64": [ 121 "include": "C:\\OpenSSL-Win64-2010\\include", 122 "lib": "C:\\OpenSSL-Win64-2010\\lib" 123 ] 124 ] 125 } 126 bat """ 127 cd cryptography 128 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH% 129 @set PYTHON="${pythonPath[toxenv]}" 130 131 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE% 132 @set LIB="${opensslPaths[label]['lib']}";%LIB% 133 tox -r -- --wycheproof-root=../wycheproof 134 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% 135 virtualenv .codecov 136 call .codecov/Scripts/activate 137 REM this pin must be kept in sync with tox.ini 138 pip install coverage 139 pip install codecov 140 codecov -e JOB_BASE_NAME,LABEL,TOXENV 141 """ 142 } else if (label.contains("sierra") || label.contains("yosemite")) { 143 ansiColor { 144 sh """#!/usr/bin/env bash 145 set -xe 146 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH 147 export PATH="/usr/local/bin:\${PATH}" 148 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}" 149 cd cryptography 150 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \ 151 LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \ 152 CFLAGS="-I/usr/local/opt/openssl\\@1.1/include -Werror -Wno-error=deprecated-declarations -Wno-error=incompatible-pointer-types-discards-qualifiers -Wno-error=unused-function -Wno-error=unused-command-line-argument -mmacosx-version-min=10.9" \ 153 tox -r -- --color=yes --wycheproof-root=../wycheproof 154 virtualenv .venv 155 source .venv/bin/activate 156 # This pin must be kept in sync with tox.ini 157 pip install coverage 158 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV 159 """ 160 } 161 } else { 162 ansiColor { 163 sh """#!/usr/bin/env bash 164 set -xe 165 cd cryptography 166 tox -r -- --color=yes --wycheproof-root=../wycheproof 167 virtualenv .venv 168 source .venv/bin/activate 169 # This pin must be kept in sync with tox.ini 170 pip install coverage 171 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME 172 """ 173 } 174 if (artifacts) { 175 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes 176 } 177 } 178 } 179 } 180 } 181 } finally { 182 deleteDir() 183 } 184 185} 186 187def builders = [:] 188for (config in configs) { 189 def label = config["label"] 190 def toxenvs = config["toxenvs"] 191 def artifacts = config["artifacts"] 192 def artifactExcludes = config["artifactExcludes"] 193 194 for (_toxenv in toxenvs) { 195 def toxenv = _toxenv 196 197 if (label.contains("docker")) { 198 def imageName = config["imageName"] 199 def combinedName = "${imageName}-${toxenv}" 200 builders[combinedName] = { 201 node(label) { 202 stage(combinedName) { 203 def buildImage = docker.image(imageName) 204 buildImage.pull() 205 buildImage.inside { 206 build(toxenv, label, imageName, artifacts, artifactExcludes) 207 } 208 } 209 } 210 } 211 } else { 212 def combinedName = "${label}-${toxenv}" 213 builders[combinedName] = { 214 node(label) { 215 stage(combinedName) { 216 build(toxenv, label, '', null, null) 217 } 218 } 219 } 220 } 221 } 222} 223 224/* Add the python setup.py test builder */ 225builders["setup.py-test"] = { 226 node("docker") { 227 stage("python setup.py test") { 228 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside { 229 try { 230 checkout_git("docker") 231 sh """#!/usr/bin/env bash 232 set -xe 233 cd cryptography 234 virtualenv .venv 235 source .venv/bin/activate 236 python setup.py test 237 """ 238 } finally { 239 deleteDir() 240 } 241 242 } 243 } 244 } 245} 246 247parallel builders 248