2018-06-11 20:53:37 +00:00
|
|
|
pipeline {
|
2018-06-13 19:57:04 +00:00
|
|
|
agent { label 'pr-lint-slave' }
|
2018-07-17 18:21:19 +00:00
|
|
|
options {
|
2018-07-17 18:26:37 +00:00
|
|
|
timestamps()
|
|
|
|
ansiColor('xterm')
|
2018-09-28 21:42:31 +00:00
|
|
|
timeout(time: 1, unit: 'HOURS')
|
2018-07-17 18:21:19 +00:00
|
|
|
}
|
2018-06-11 20:53:37 +00:00
|
|
|
environment {
|
|
|
|
PYENV_ROOT = "/usr/local/pyenv"
|
|
|
|
PATH = "$PYENV_ROOT/bin:$PATH"
|
2018-07-17 19:57:00 +00:00
|
|
|
PY_COLORS = 1
|
2018-06-11 20:53:37 +00:00
|
|
|
}
|
|
|
|
stages {
|
2018-06-19 22:55:05 +00:00
|
|
|
stage('github-pending') {
|
|
|
|
steps {
|
|
|
|
githubNotify credentialsId: 'test-jenkins-credentials',
|
|
|
|
description: 'Testing lint...',
|
|
|
|
status: 'PENDING',
|
|
|
|
context: "jenkins/pr/lint"
|
|
|
|
}
|
|
|
|
}
|
2018-06-13 19:57:04 +00:00
|
|
|
stage('setup') {
|
2018-06-11 20:53:37 +00:00
|
|
|
steps {
|
2018-08-10 23:27:58 +00:00
|
|
|
sh '''
|
|
|
|
eval "$(pyenv init -)"
|
|
|
|
pyenv --version
|
|
|
|
pyenv install --skip-existing 2.7.14
|
|
|
|
pyenv local 2.7.14
|
|
|
|
pyenv shell 2.7.14
|
|
|
|
python --version
|
|
|
|
pip install tox
|
|
|
|
'''
|
2018-06-11 20:53:37 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-11 22:57:55 +00:00
|
|
|
stage('linting') {
|
|
|
|
failFast false
|
|
|
|
parallel {
|
|
|
|
stage('salt linting') {
|
|
|
|
steps {
|
2018-08-10 23:27:58 +00:00
|
|
|
sh '''
|
|
|
|
eval "$(pyenv init - --no-rehash)"
|
|
|
|
_FILES="$(find salt/ -name "*.py" -exec git diff --name-only "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" {} +)"
|
|
|
|
_FILES="$_FILES $(git diff --name-only "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" setup.py)"
|
|
|
|
if [[ -z ${_FILES} ]]; then
|
|
|
|
echo "No pylint run, no changes found in the files"
|
|
|
|
echo "empty" pylint-reports.xml
|
|
|
|
else
|
|
|
|
tox -e pylint-salt ${_FILES} | tee pylint-report.xml
|
|
|
|
fi
|
|
|
|
'''
|
2018-06-11 22:57:55 +00:00
|
|
|
archiveArtifacts artifacts: 'pylint-report.xml'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('test linting') {
|
|
|
|
steps {
|
2018-08-10 23:27:58 +00:00
|
|
|
sh '''
|
|
|
|
eval "$(pyenv init - --no-rehash)"
|
|
|
|
_FILES="$(find tests/ -name "*.py" -exec git diff --name-only "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" setup.py {} +)"
|
|
|
|
if [[ -z ${_FILES} ]]; then
|
|
|
|
echo "No pylint run, no changes found in the files"
|
|
|
|
touch pylint-report-tests.xml
|
|
|
|
else
|
|
|
|
tox -e pylint-tests ${_FILES} | tee pylint-report-tests.xml
|
|
|
|
fi
|
|
|
|
'''
|
2018-06-11 22:57:55 +00:00
|
|
|
archiveArtifacts artifacts: 'pylint-report-tests.xml'
|
|
|
|
}
|
|
|
|
}
|
2018-06-11 20:53:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
2018-06-26 22:55:11 +00:00
|
|
|
always {
|
|
|
|
step([$class: 'WarningsPublisher',
|
|
|
|
parserConfigurations: [[
|
|
|
|
parserName: 'PyLint',
|
|
|
|
pattern: 'pylint-report*.xml'
|
|
|
|
]],
|
2018-07-26 19:19:07 +00:00
|
|
|
failedTotalAll: '0',
|
|
|
|
useDeltaValues: false,
|
|
|
|
canRunOnFailed: true,
|
2018-06-26 22:55:11 +00:00
|
|
|
usePreviousBuildAsReference: true
|
|
|
|
])
|
2018-06-29 18:07:08 +00:00
|
|
|
cleanWs()
|
2018-06-26 22:55:11 +00:00
|
|
|
}
|
2018-06-11 20:53:37 +00:00
|
|
|
success {
|
2018-06-19 20:58:38 +00:00
|
|
|
githubNotify credentialsId: 'test-jenkins-credentials',
|
|
|
|
description: 'The lint job has passed',
|
|
|
|
status: 'SUCCESS',
|
|
|
|
context: "jenkins/pr/lint"
|
2018-06-11 20:53:37 +00:00
|
|
|
}
|
|
|
|
failure {
|
2018-06-19 20:58:38 +00:00
|
|
|
githubNotify credentialsId: 'test-jenkins-credentials',
|
|
|
|
description: 'The lint job has failed',
|
|
|
|
status: 'FAILURE',
|
|
|
|
context: "jenkins/pr/lint"
|
2018-10-05 14:46:15 +00:00
|
|
|
slackSend channel: "#jenkins-prod-pr",
|
|
|
|
color: '#FF0000',
|
|
|
|
message: "FAILED: PR-Job: '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
|
2018-06-11 20:53:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|