-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkinsfile.groovy
125 lines (109 loc) · 4.54 KB
/
jenkinsfile.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
def repository = 'hydro-serving-integrations'
def buildAndPublishReleaseFunction = {
withCredentials([
string(credentialsId: 'HydrosphereDevEndpoint', variable: 'HYDROSPHERE_ENDPOINT'),
string(credentialsId: 'HydroIntegrationsAWSRegion', variable: 'AWS_DEFAULT_REGION'),
string(credentialsId: 'HydroIntegrationsS3DataCaptureBucket', variable: 'S3_DATA_CAPTURE_BUCKET'),
string(credentialsId: 'HydroIntegrationsS3DataCapturePrefix', variable: 'S3_DATA_CAPTURE_PREFIX'),
string(credentialsId: 'HydroIntegrationsS3DataTrainingBucket', variable: 'S3_DATA_TRAINING_BUCKET'),
string(credentialsId: 'HydroIntegrationsS3DataTrainingPrefix', variable: 'S3_DATA_TRAINING_PREFIX'),
[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'aws-hydrosphere-jenkins-credentials',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
],
]) {
configFileProvider([configFile(fileId: 'PYPIDeployConfiguration', targetLocation: '.pypirc', variable: 'PYPI_SETTINGS')]) {
sh """#!/bin/bash
set -ex
# prepare environment
pyenv install --skip-existing 3.6.10
pyenv install --skip-existing 3.7.7
pyenv install --skip-existing 3.8.2
eval "\$(pyenv init -)"
pyenv shell 3.6.10 3.7.7 3.8.2
python -m venv venv
source venv/bin/activate
pip install wheel~=0.34.2
pip install tox~=3.14.5
pip install aws-sam-cli~=0.47.0
pip install twine~=3.1.1
pip install awscli~=1.18.44
# run tests for lambda distribution
# and for hydro-integrations sdk
tox
# build lambda distribution artifacts
cd scripts/aws/traffic_shadowing
./sam-build.sh
./sam-package.sh
# publish lambda distribution artifacts
./cf-build-upload.sh
cd ../../../
rm -rf dist/
# build hydro-integrations sdk
pip install -r requirements.txt
python setup.py bdist_wheel
# publish hydro-integrations sdk package
python -m twine upload --config-file ${env.WORKSPACE}/.pypirc -r pypi ${env.WORKSPACE}/dist/*
deactivate
"""
}
}
}
def buildFunction = {
withCredentials([
string(credentialsId: 'HydrosphereDevEndpoint', variable: 'HYDROSPHERE_ENDPOINT'),
string(credentialsId: 'HydroIntegrationsAWSRegion', variable: 'AWS_DEFAULT_REGION'),
string(credentialsId: 'HydroIntegrationsS3DataCaptureBucket', variable: 'S3_DATA_CAPTURE_BUCKET'),
string(credentialsId: 'HydroIntegrationsS3DataCapturePrefix', variable: 'S3_DATA_CAPTURE_PREFIX'),
string(credentialsId: 'HydroIntegrationsS3DataTrainingBucket', variable: 'S3_DATA_TRAINING_BUCKET'),
string(credentialsId: 'HydroIntegrationsS3DataTrainingPrefix', variable: 'S3_DATA_TRAINING_PREFIX'),
[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'aws-hydrosphere-jenkins-credentials',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
],
]) {
sh """#!/bin/bash
set -ex
# prepare environment
pyenv install --skip-existing 3.6.10
pyenv install --skip-existing 3.7.7
pyenv install --skip-existing 3.8.2
eval "\$(pyenv init -)"
pyenv shell 3.6.10 3.7.7 3.8.2
python -m venv venv
source venv/bin/activate
pip install wheel~=0.34.2
pip install tox~=3.14.5
pip install aws-sam-cli~=0.47.0
# run tests for lambda distribution
# and for hydro-integrations sdk
tox
# check that lambda distribution
# can be built
cd scripts/aws/traffic_shadowing
./sam-build.sh
cd ../../../
# check that hydro-integrations
# sdk can be built
pip install -r requirements.txt
python setup.py bdist_wheel
deactivate
"""
}
}
def collectTestResults = {
junit testResults: 'test-report.xml', allowEmptyResults: true
}
pipelineCommon(
repository,
false, //needSonarQualityGate,
[],
collectTestResults,
buildAndPublishReleaseFunction,
buildFunction,
buildFunction
)