pyannotators-patterns 1.6.25__tar.gz → 1.6.29__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/PKG-INFO +1 -1
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/pyproject.toml +15 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/src/pyannotators_patterns/__init__.py +1 -1
- pyannotators_patterns-1.6.25/Dockerfile +0 -19
- pyannotators_patterns-1.6.25/Jenkinsfile +0 -496
- pyannotators_patterns-1.6.25/MIGRATION.md +0 -166
- pyannotators_patterns-1.6.25/bumpversion.py +0 -41
- pyannotators_patterns-1.6.25/docs/.gitignore +0 -2
- pyannotators_patterns-1.6.25/docs/CHANGELOG.md +0 -7
- pyannotators_patterns-1.6.25/docs/LICENSE +0 -21
- pyannotators_patterns-1.6.25/docs/_static/.gitkeep +0 -0
- pyannotators_patterns-1.6.25/docs/_templates/.gitkeep +0 -0
- pyannotators_patterns-1.6.25/docs/conf.py +0 -83
- pyannotators_patterns-1.6.25/docs/index.rst +0 -9
- pyannotators_patterns-1.6.25/mypy.ini +0 -6
- pyannotators_patterns-1.6.25/tests/assertions.py +0 -27
- pyannotators_patterns-1.6.25/tests/data/coords-document.json +0 -8
- pyannotators_patterns-1.6.25/tests/data/coords.json +0 -15
- pyannotators_patterns-1.6.25/tests/data/mgrs-document.json +0 -8
- pyannotators_patterns-1.6.25/tests/data/mgrs.json +0 -10
- pyannotators_patterns-1.6.25/tests/data/tel-document.json +0 -8
- pyannotators_patterns-1.6.25/tests/data/tel.json +0 -21
- pyannotators_patterns-1.6.25/tests/test_annotator.py +0 -172
- pyannotators_patterns-1.6.25/tests/test_coords.py +0 -42
- pyannotators_patterns-1.6.25/tests/test_credit_cards.py +0 -111
- pyannotators_patterns-1.6.25/tests/test_emails.py +0 -75
- pyannotators_patterns-1.6.25/tests/test_mgrs.py +0 -25
- pyannotators_patterns-1.6.25/tests/test_tel.py +0 -33
- pyannotators_patterns-1.6.25/tests/test_zip.py +0 -60
- pyannotators_patterns-1.6.25/trivy-html-template.tpl +0 -148
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/.bumpversion.cfg +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/.github/workflows/main.yml +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/.gitignore +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/.pre-commit-config.yaml +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/.readthedocs.yml +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/AUTHORS.md +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/CHANGELOG.md +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/LICENSE +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/README.md +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/RELEASE.md +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/src/pyannotators_patterns/named_pattern_recognizer.py +0 -0
- {pyannotators_patterns-1.6.25 → pyannotators_patterns-1.6.29}/src/pyannotators_patterns/patterns.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyannotators-patterns
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.29
|
|
4
4
|
Summary: Annotator based on Presidio pattern recognizer
|
|
5
5
|
Project-URL: Homepage, https://github.com/oterrier/pyannotators_patterns/
|
|
6
6
|
Author-email: Olivier Terrier <olivier.terrier@kairntech.com>
|
|
@@ -71,6 +71,21 @@ path = "src/pyannotators_patterns/__init__.py"
|
|
|
71
71
|
[tool.hatch.build.targets.wheel]
|
|
72
72
|
packages = ["src/pyannotators_patterns"]
|
|
73
73
|
|
|
74
|
+
[tool.hatch.build]
|
|
75
|
+
exclude = [
|
|
76
|
+
"/tests",
|
|
77
|
+
"/docs",
|
|
78
|
+
"Jenkinsfile",
|
|
79
|
+
"Dockerfile",
|
|
80
|
+
"bumpversion.py",
|
|
81
|
+
"mypy.ini",
|
|
82
|
+
"hgnc_cache.sqlite",
|
|
83
|
+
"trivy-html-template.tpl",
|
|
84
|
+
"MIGRATION.md",
|
|
85
|
+
".gitignore",
|
|
86
|
+
".dockerignore"
|
|
87
|
+
]
|
|
88
|
+
|
|
74
89
|
[tool.pytest.ini_options]
|
|
75
90
|
addopts = "--durations=5"
|
|
76
91
|
norecursedirs = ["docs"]
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
FROM python:3.12-slim-bookworm
|
|
2
|
-
# Install prerequisites
|
|
3
|
-
RUN apt-get update -y && \
|
|
4
|
-
apt-get install -y \
|
|
5
|
-
patch \
|
|
6
|
-
gcc && \
|
|
7
|
-
apt-get install -y --no-install-recommends \
|
|
8
|
-
g++ \
|
|
9
|
-
git && \
|
|
10
|
-
# Final upgrade + clean
|
|
11
|
-
apt-get update -y && \
|
|
12
|
-
apt-get clean all -y
|
|
13
|
-
|
|
14
|
-
# Install uv
|
|
15
|
-
RUN pip install uv
|
|
16
|
-
|
|
17
|
-
# Add pyproject.toml + README.md for uv install
|
|
18
|
-
ADD pyproject.toml pyproject.toml
|
|
19
|
-
ADD README.md README.md
|
|
@@ -1,496 +0,0 @@
|
|
|
1
|
-
#!groovy
|
|
2
|
-
// to test groovy snippets online:
|
|
3
|
-
// https://www.jdoodle.com/execute-groovy-online
|
|
4
|
-
|
|
5
|
-
pipeline {
|
|
6
|
-
|
|
7
|
-
agent none
|
|
8
|
-
|
|
9
|
-
options {
|
|
10
|
-
throttleJobProperty(
|
|
11
|
-
categories: ['pyannotators'],
|
|
12
|
-
throttleEnabled: true,
|
|
13
|
-
throttleOption: 'category'
|
|
14
|
-
)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
triggers {
|
|
18
|
-
upstream(upstreamProjects: 'pymultirole_plugins/' + BRANCH_NAME.replaceAll('/', '%2F'),\
|
|
19
|
-
threshold: hudson.model.Result.SUCCESS)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// variables declared in environment block can not be changed in any steps/stages
|
|
23
|
-
environment {
|
|
24
|
-
PATH_HOME = '/home/jenkins'
|
|
25
|
-
TEST_REPORT_DIR = '/root/test-reports'
|
|
26
|
-
PYTHONPYCACHEPREFIX = '/tmp/.pytest_cache'
|
|
27
|
-
PYTHONDONTWRITEBYTECODE = '1'
|
|
28
|
-
JENKINS_UIDGID = '1004:1004'
|
|
29
|
-
SBOM_PROJECT_NAME = "sbom-${JOB_NAME.replaceAll('[^a-zA-Z0-9_.-]', '_')}"
|
|
30
|
-
|
|
31
|
-
MAJOR_VERSION = "${MAJOR_VERSION_PY312}"
|
|
32
|
-
MINOR_VERSION = "${MINOR_VERSION_PY312}"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
stages {
|
|
36
|
-
stage('Catch build termination') {
|
|
37
|
-
agent {
|
|
38
|
-
node {
|
|
39
|
-
label 'pre-build'
|
|
40
|
-
customWorkspace "${PATH_HOME}/${JOB_NAME}"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
stages {
|
|
44
|
-
stage('Analyse build cause') {
|
|
45
|
-
steps {
|
|
46
|
-
script {
|
|
47
|
-
analyseBuildCause()
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
stage('Generate new version') {
|
|
55
|
-
when {
|
|
56
|
-
environment name: 'SKIP_JOB', value: '0'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
agent {
|
|
60
|
-
node {
|
|
61
|
-
label 'built-in'
|
|
62
|
-
customWorkspace "${PATH_HOME}/${JOB_NAME}"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
stages {
|
|
67
|
-
stage('Add credentials') {
|
|
68
|
-
steps {
|
|
69
|
-
script {
|
|
70
|
-
// Add password file for uv publishing
|
|
71
|
-
sh "cp ${PATH_HOME}/.passwd-pypi .env"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
stage('Commit new version') {
|
|
77
|
-
steps {
|
|
78
|
-
script {
|
|
79
|
-
println("attempt to publish ${JOB_NAME} with version: ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_ID}")
|
|
80
|
-
|
|
81
|
-
// push updates of file __init__.py
|
|
82
|
-
withCredentials([gitUsernamePassword(credentialsId: 'bitbucket-user', gitToolName: 'git-tool')]) {
|
|
83
|
-
sh 'git pull'
|
|
84
|
-
sh "echo '\"\"\"Annotator based on Presidio pattern recognizer\"\"\"' > src/pyannotators_patterns/__init__.py"
|
|
85
|
-
sh "echo '' >> src/pyannotators_patterns/__init__.py"
|
|
86
|
-
sh "echo '__version__ = \"${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_ID}\"' >> src/pyannotators_patterns/__init__.py"
|
|
87
|
-
sh 'git commit src/pyannotators_patterns/__init__.py -m "[Jenkins CI] Commit on version files" || echo "No changes to commit"'
|
|
88
|
-
sh 'git push'
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
stage('Build, test and publish') {
|
|
97
|
-
when {
|
|
98
|
-
beforeAgent true
|
|
99
|
-
environment name: 'SKIP_JOB', value: '0'
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
agent {
|
|
103
|
-
// dockerfile agent
|
|
104
|
-
// Mounted volume for Junit reports
|
|
105
|
-
// - docker: /root/test-reports
|
|
106
|
-
// - host : /tmp/_${JOB_NAME}/test-reports
|
|
107
|
-
dockerfile {
|
|
108
|
-
label 'docker-build'
|
|
109
|
-
customWorkspace "${PATH_HOME}/${JOB_NAME}"
|
|
110
|
-
filename 'Dockerfile'
|
|
111
|
-
args "-u root --privileged -v /tmp/_${JOB_NAME}/test-reports:${TEST_REPORT_DIR}"
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
stages {
|
|
116
|
-
stage('Install dependencies') {
|
|
117
|
-
steps {
|
|
118
|
-
sh 'rm -f uv.lock'
|
|
119
|
-
sh 'pip install uv'
|
|
120
|
-
sh 'uv sync --no-cache --extra test'
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
stage('Test & lint python code') {
|
|
125
|
-
steps {
|
|
126
|
-
// remove any previous results.xml file
|
|
127
|
-
sh "rm -f ${TEST_REPORT_DIR}/results.xml"
|
|
128
|
-
sh 'uv run ruff check .'
|
|
129
|
-
sh 'uv run ruff format --check .'
|
|
130
|
-
sh "uv run pytest --junit-xml=${TEST_REPORT_DIR}/results.xml"
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
stage('Publish on PyPI') {
|
|
135
|
-
environment {
|
|
136
|
-
UV_PUBLISH_USERNAME = getUserName '.env'
|
|
137
|
-
UV_PUBLISH_PASSWORD = getUserPass '.env'
|
|
138
|
-
}
|
|
139
|
-
steps {
|
|
140
|
-
// remove any previous folder dist
|
|
141
|
-
sh 'rm -rf dist'
|
|
142
|
-
// remove any previous files used for sbom
|
|
143
|
-
sh 'rm -f sbom*.json trivy*.html syft trivy'
|
|
144
|
-
// pull recent updates of file __init__.py
|
|
145
|
-
withCredentials([gitUsernamePassword(credentialsId: 'bitbucket-user', gitToolName: 'git-tool')]) {
|
|
146
|
-
sh 'git config --global pull.rebase false'
|
|
147
|
-
sh "git config --global --add safe.directory ${WORKSPACE}"
|
|
148
|
-
sh 'git pull'
|
|
149
|
-
}
|
|
150
|
-
// put back owner of .git folder
|
|
151
|
-
sh "chown -R ${JENKINS_UIDGID} ${WORKSPACE}/.git"
|
|
152
|
-
// put back owner of pulled file
|
|
153
|
-
sh "chown ${JENKINS_UIDGID} src/pyannotators_patterns/__init__.py"
|
|
154
|
-
// get git status
|
|
155
|
-
sh 'git status'
|
|
156
|
-
// build and publish on PyPI
|
|
157
|
-
sh '''
|
|
158
|
-
export COMMIT_VERSION=$( cat src/pyannotators_patterns/__init__.py|grep version|cut -d '"' -f2|tr -s '[:blank:]' )
|
|
159
|
-
export BUILD_VERSION="${MAJOR_VERSION}"."${MINOR_VERSION}"."${BUILD_ID}"
|
|
160
|
-
if [ "${COMMIT_VERSION}" = "${BUILD_VERSION}" ] ; then uv build && uv publish ; fi
|
|
161
|
-
'''
|
|
162
|
-
// remove current folder dist
|
|
163
|
-
sh 'rm -rf dist'
|
|
164
|
-
// remove current folder .hypothesis
|
|
165
|
-
sh 'rm -rf .hypothesis'
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
stage('Prepare SBOM') {
|
|
172
|
-
when {
|
|
173
|
-
beforeAgent true
|
|
174
|
-
environment name: 'SKIP_JOB', value: '0'
|
|
175
|
-
}
|
|
176
|
-
options {
|
|
177
|
-
timeout(time: 120, unit: 'SECONDS')
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
agent {
|
|
181
|
-
docker {
|
|
182
|
-
image 'alpine:3.19'
|
|
183
|
-
label 'docker-build'
|
|
184
|
-
customWorkspace "${PATH_HOME}/${JOB_NAME}"
|
|
185
|
-
args "-u 0 -v ${PATH_HOME}/.cache/trivy:/root/.cache/trivy"
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
stages {
|
|
190
|
-
stage('Generate SBOM') {
|
|
191
|
-
steps {
|
|
192
|
-
sh """
|
|
193
|
-
apk add --no-cache curl
|
|
194
|
-
|
|
195
|
-
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b . v${SYFT_VERSION}
|
|
196
|
-
|
|
197
|
-
./syft . \
|
|
198
|
-
--exclude '**/syft' \
|
|
199
|
-
--exclude '**/.pytest_cache' \
|
|
200
|
-
--exclude '**/.ruff_cache' \
|
|
201
|
-
--exclude '**/sbom.cdx.json' \
|
|
202
|
-
--exclude '**/sbom.spdx.json' \
|
|
203
|
-
--source-name "${JOB_NAME}" \
|
|
204
|
-
--source-version "${BUILD_NUMBER}" \
|
|
205
|
-
-o cyclonedx-json=${SBOM_PROJECT_NAME}.cdx.json \
|
|
206
|
-
-o spdx-json=${SBOM_PROJECT_NAME}.spdx.json
|
|
207
|
-
|
|
208
|
-
rm -f ./syft
|
|
209
|
-
"""
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
stage('Analyse SBOM') {
|
|
214
|
-
steps {
|
|
215
|
-
sh """
|
|
216
|
-
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b . v${TRIVY_VERSION}
|
|
217
|
-
if [ ! -f trivy-html-template.tpl ]; then
|
|
218
|
-
curl -L https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html-template.tpl
|
|
219
|
-
fi
|
|
220
|
-
|
|
221
|
-
./trivy sbom ${SBOM_PROJECT_NAME}.cdx.json \
|
|
222
|
-
--cache-dir "/root/.cache/trivy" \
|
|
223
|
-
--severity HIGH,CRITICAL \
|
|
224
|
-
--exit-code 1 \
|
|
225
|
-
--no-progress \
|
|
226
|
-
--format template \
|
|
227
|
-
--template "@trivy-html-template.tpl" \
|
|
228
|
-
-o trivy-report-${SBOM_PROJECT_NAME}.html || EXIT_CODE=\$?
|
|
229
|
-
|
|
230
|
-
rm -f ./trivy
|
|
231
|
-
|
|
232
|
-
exit \${EXIT_CODE:-0}
|
|
233
|
-
"""
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
stage('Archive SBOM & analysis') {
|
|
238
|
-
steps {
|
|
239
|
-
archiveArtifacts artifacts: 'sbom*.json, trivy*.html', excludes: 'sbom.cdx.json, sbom.spdx.json', fingerprint: true
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
post {
|
|
247
|
-
// only triggered when blue or green sign
|
|
248
|
-
success {
|
|
249
|
-
// node is specified here to get an agent
|
|
250
|
-
node('built-in') {
|
|
251
|
-
// keep using customWorkspace to store Junit report
|
|
252
|
-
ws("${PATH_HOME}/${JOB_NAME}") {
|
|
253
|
-
script {
|
|
254
|
-
try {
|
|
255
|
-
sh 'rm -f results.xml'
|
|
256
|
-
sh "cp /tmp/_${JOB_NAME}/test-reports/results.xml results.xml"
|
|
257
|
-
} catch (Exception e) {
|
|
258
|
-
println 'Exception occurred: ' + e.toString()
|
|
259
|
-
}
|
|
260
|
-
try {
|
|
261
|
-
junit 'results.xml'
|
|
262
|
-
} catch (Exception e) {
|
|
263
|
-
println 'Exception occurred: ' + e.toString()
|
|
264
|
-
}
|
|
265
|
-
if (sendEmailNotif("${PATH_HOME}/${JOB_NAME}", "${BUILD_NUMBER}")) {
|
|
266
|
-
println 'sending Success Build notification'
|
|
267
|
-
def CUSTOM_SUBJECT = '[CI - Jenkinzz SUCCESS] ' + CUSTOM_SUBJECT
|
|
268
|
-
emailext(
|
|
269
|
-
mimeType: 'text/html',
|
|
270
|
-
subject: CUSTOM_SUBJECT,
|
|
271
|
-
body: '${DEFAULT_CONTENT}',
|
|
272
|
-
replyTo: '${DEFAULT_REPLYTO}',
|
|
273
|
-
to: '${ADMIN_RECIPIENTS}' + ';' + CUSTOM_RECIPIENTS
|
|
274
|
-
)
|
|
275
|
-
switchEmailNotif(false, BUILD_NUMBER)
|
|
276
|
-
} else {
|
|
277
|
-
println 'preventing Success Build notification'
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// triggered when red sign
|
|
284
|
-
failure {
|
|
285
|
-
// node is specified here to get an agent
|
|
286
|
-
node('built-in') {
|
|
287
|
-
// keep using customWorkspace to store Junit report
|
|
288
|
-
ws("${PATH_HOME}/${JOB_NAME}") {
|
|
289
|
-
script {
|
|
290
|
-
try {
|
|
291
|
-
sh 'rm -f results.xml'
|
|
292
|
-
sh "cp /tmp/_${JOB_NAME}/test-reports/results.xml results.xml"
|
|
293
|
-
} catch (Exception e) {
|
|
294
|
-
println 'Exception occurred: ' + e.toString()
|
|
295
|
-
}
|
|
296
|
-
try {
|
|
297
|
-
junit 'results.xml'
|
|
298
|
-
} catch (Exception e) {
|
|
299
|
-
println 'Exception occurred: ' + e.toString()
|
|
300
|
-
}
|
|
301
|
-
println 'sending Failure Build notification'
|
|
302
|
-
def CUSTOM_SUBJECT = '[CI - Jenkinzz FAILURE] ' + CUSTOM_SUBJECT
|
|
303
|
-
emailext(
|
|
304
|
-
mimeType: 'text/html',
|
|
305
|
-
subject: CUSTOM_SUBJECT,
|
|
306
|
-
body: '${DEFAULT_CONTENT}',
|
|
307
|
-
replyTo: '${DEFAULT_REPLYTO}',
|
|
308
|
-
to: '${ADMIN_RECIPIENTS}' + ';' + CUSTOM_RECIPIENTS
|
|
309
|
-
)
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
// triggered when black sign
|
|
315
|
-
aborted {
|
|
316
|
-
println 'post-declarative message: abort job'
|
|
317
|
-
}
|
|
318
|
-
// trigger every-works
|
|
319
|
-
//always {
|
|
320
|
-
//}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// return UV_PUBLISH_USERNAME from given file (reads FLIT_USERNAME key)
|
|
325
|
-
def getUserName(path) {
|
|
326
|
-
def USERNAME = sh(
|
|
327
|
-
script: "grep FLIT_USERNAME ${path}|cut -d '=' -f2",
|
|
328
|
-
returnStdout: true
|
|
329
|
-
).trim()
|
|
330
|
-
return USERNAME
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// return UV_PUBLISH_PASSWORD from given file (reads FLIT_PASSWORD key)
|
|
334
|
-
def getUserPass(path) {
|
|
335
|
-
def USERPASS = sh(
|
|
336
|
-
script: "grep FLIT_PASSWORD ${path}|cut -d '=' -f2",
|
|
337
|
-
returnStdout: true
|
|
338
|
-
).trim()
|
|
339
|
-
return USERPASS
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// create/remove emailNotif file to trigger email notification
|
|
343
|
-
def switchEmailNotif(toggle, build) {
|
|
344
|
-
if (toggle) {
|
|
345
|
-
sh 'echo ' + build + ' > .emailNotif'
|
|
346
|
-
} else {
|
|
347
|
-
if (build == BUILD_NUMBER) {
|
|
348
|
-
sh 'rm -f .emailNotif'
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// return true if emailNotif file present
|
|
354
|
-
boolean sendEmailNotif(path, build) {
|
|
355
|
-
def emailNotif = sh(
|
|
356
|
-
script: "find ${path} -name '.emailNotif'|wc -l",
|
|
357
|
-
returnStdout: true
|
|
358
|
-
).trim()
|
|
359
|
-
def emailContent = ''
|
|
360
|
-
if (emailNotif == '1') {
|
|
361
|
-
emailContent = sh(
|
|
362
|
-
script: "cat ${path}/.emailNotif",
|
|
363
|
-
returnStdout: true
|
|
364
|
-
).trim()
|
|
365
|
-
}
|
|
366
|
-
return (emailContent == build)
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
def analyseBuildCause() {
|
|
370
|
-
String[] upstreamProjects = ['pymultirole_plugins']
|
|
371
|
-
boolean upstreamRunning = false
|
|
372
|
-
String jobName
|
|
373
|
-
// iterate over upstreamProjects
|
|
374
|
-
for (upstream_project in upstreamProjects) {
|
|
375
|
-
Jenkins.instance.getItemByFullName(upstream_project).items.each { repository ->
|
|
376
|
-
boolean isRunning = false
|
|
377
|
-
//repository.parent.name: project
|
|
378
|
-
//repository.name: branch
|
|
379
|
-
if ( repository.name == BRANCH_NAME ) {
|
|
380
|
-
// iterate over all jobs of current repository
|
|
381
|
-
repository.allJobs.each { job ->
|
|
382
|
-
// iterate over all builds of current job
|
|
383
|
-
job.builds.each { build ->
|
|
384
|
-
// determine if a build is running or not
|
|
385
|
-
if ( build.result == (null) ) {
|
|
386
|
-
jobName = build.parent.parent.name
|
|
387
|
-
isRunning = true
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
if ( isRunning ) {
|
|
391
|
-
upstreamRunning = true
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// Catch if build has been triggered by CI Commit
|
|
399
|
-
// returnStatus = true when string not found -> Team commit
|
|
400
|
-
// returnStatus = false when string is found -> CI commit
|
|
401
|
-
boolean lastCommitIsTeam = sh(
|
|
402
|
-
script: 'git log -1 | grep "\\[Jenkins CI\\]"',
|
|
403
|
-
returnStatus: true
|
|
404
|
-
)
|
|
405
|
-
|
|
406
|
-
// Skip build when upstream detected
|
|
407
|
-
if (upstreamRunning) {
|
|
408
|
-
println 'Skipping build because upstream job detected (' + jobName + ')'
|
|
409
|
-
env.SKIP_JOB = '1'
|
|
410
|
-
switchEmailNotif(false, 0)
|
|
411
|
-
currentBuild.result = 'NOT_BUILT'
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Catch if build has been triggered by User
|
|
415
|
-
boolean isStartedByUser = currentBuild.rawBuild.getCause(hudson.model.Cause$UserIdCause) != null
|
|
416
|
-
if (isStartedByUser && !upstreamRunning) {
|
|
417
|
-
env.SKIP_JOB = '0'
|
|
418
|
-
env.CUSTOM_SUBJECT = JOB_NAME + ' - Manual Build #' + BUILD_NUMBER
|
|
419
|
-
env.CUSTOM_RECIPIENTS = emailextrecipients([[$class: 'RequesterRecipientProvider']])
|
|
420
|
-
switchEmailNotif(true, BUILD_NUMBER)
|
|
421
|
-
println 'Job started by User, proceeding'
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// Catch if build has been triggered by Upstream
|
|
425
|
-
boolean isStartedByUpstream = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) != null
|
|
426
|
-
if (isStartedByUpstream && !upstreamRunning) {
|
|
427
|
-
int changeSetCount = 0
|
|
428
|
-
int ciSkipCount = 0
|
|
429
|
-
String upstreamFullJobName = ''
|
|
430
|
-
for (Run upstreamBuild : currentBuild.upstreamBuilds) {
|
|
431
|
-
upstreamFullJobName = upstreamBuild.rawBuild.fullDisplayName
|
|
432
|
-
if (upstreamBuild.changeSets != null) {
|
|
433
|
-
def changeLogSets = upstreamBuild.changeSets
|
|
434
|
-
for (int i = 0; i < changeLogSets.size(); i++) {
|
|
435
|
-
changeSetCount++
|
|
436
|
-
def entries = changeLogSets[i].items
|
|
437
|
-
for (int j = 0; j < entries.length; j++) {
|
|
438
|
-
def entry = entries[j]
|
|
439
|
-
if (entry.msg.contains('[Jenkins CI]')) {
|
|
440
|
-
ciSkipCount++
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (changeSetCount > 0 && changeSetCount == ciSkipCount) {
|
|
447
|
-
env.SKIP_JOB = '1'
|
|
448
|
-
switchEmailNotif(false, 0)
|
|
449
|
-
println 'Job started by Upstream [' + upstreamFullJobName + '], with CI commit, skipping'
|
|
450
|
-
currentBuild.result = 'NOT_BUILT'
|
|
451
|
-
} else {
|
|
452
|
-
env.SKIP_JOB = '0'
|
|
453
|
-
env.CUSTOM_SUBJECT = JOB_NAME + ' - Upstream Build #' + BUILD_NUMBER
|
|
454
|
-
env.CUSTOM_RECIPIENTS = emailextrecipients([[$class:'UpstreamComitterRecipientProvider']])
|
|
455
|
-
switchEmailNotif(true, BUILD_NUMBER)
|
|
456
|
-
println 'Job started by Upstream [' + upstreamFullJobName + '], proceeding'
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// Catch if build has been triggered by User Commit
|
|
461
|
-
boolean isStartedByCommit = currentBuild.rawBuild.getCause(jenkins.branch.BranchEventCause) != null
|
|
462
|
-
if (isStartedByCommit && lastCommitIsTeam && !upstreamRunning) {
|
|
463
|
-
env.SKIP_JOB = '0'
|
|
464
|
-
env.CUSTOM_SUBJECT = JOB_NAME + ' - SCM Build #' + BUILD_NUMBER
|
|
465
|
-
env.CUSTOM_RECIPIENTS = emailextrecipients([[$class: 'DevelopersRecipientProvider'], [$class:'CulpritsRecipientProvider']])
|
|
466
|
-
switchEmailNotif(true, BUILD_NUMBER)
|
|
467
|
-
println 'Job started by User Commit, proceeding'
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// Catch if build has been triggered by cron
|
|
471
|
-
boolean isStartedByCron = currentBuild.rawBuild.getCause(hudson.triggers.TimerTrigger$TimerTriggerCause) != null
|
|
472
|
-
if (isStartedByCron && lastCommitIsTeam && !upstreamRunning) {
|
|
473
|
-
env.SKIP_JOB = '0'
|
|
474
|
-
env.CUSTOM_SUBJECT = JOB_NAME + ' - CRON Build #' + BUILD_NUMBER
|
|
475
|
-
env.CUSTOM_RECIPIENTS = emailextrecipients([[$class: 'DevelopersRecipientProvider'], [$class:'CulpritsRecipientProvider']])
|
|
476
|
-
switchEmailNotif(true, BUILD_NUMBER)
|
|
477
|
-
println 'Job started by Cron, proceeding'
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// Catch if build has been triggered by branch discovery
|
|
481
|
-
boolean isStartedByBranchDiscovery = currentBuild.rawBuild.getCause(jenkins.branch.BranchIndexingCause) != null
|
|
482
|
-
if (isStartedByBranchDiscovery && lastCommitIsTeam && !upstreamRunning) {
|
|
483
|
-
env.SKIP_JOB = '0'
|
|
484
|
-
env.CUSTOM_SUBJECT = JOB_NAME + ' - BranchDiscovery Build #' + BUILD_NUMBER
|
|
485
|
-
env.CUSTOM_RECIPIENTS = emailextrecipients([[$class: 'DevelopersRecipientProvider'], [$class:'CulpritsRecipientProvider']])
|
|
486
|
-
switchEmailNotif(true, BUILD_NUMBER)
|
|
487
|
-
println 'Job started by Branch Discovery, proceeding'
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
if (!lastCommitIsTeam && !upstreamRunning && !isStartedByUser && !isStartedByUpstream) {
|
|
491
|
-
println 'Skipping build because last commit has been done by CI'
|
|
492
|
-
env.SKIP_JOB = '1'
|
|
493
|
-
switchEmailNotif(false, 0)
|
|
494
|
-
currentBuild.result = 'NOT_BUILT'
|
|
495
|
-
}
|
|
496
|
-
}
|