docs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Define the maximum time, in hours, that a test run should run for
  2. def global_timeout = 2
  3. def salt_target_branch = '2019.2'
  4. properties([
  5. buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')),
  6. ])
  7. def shell_header
  8. node('docs') {
  9. timeout(time: global_timeout, unit: 'HOURS') {
  10. ansiColor('xterm') {
  11. timestamps {
  12. try {
  13. // Set the GH status even before cloning the repo
  14. if (env.NODE_NAME.startsWith('jenkins-pr-')) {
  15. stage('github-pending') {
  16. githubNotify credentialsId: 'test-jenkins-credentials',
  17. description: 'Testing docs...',
  18. status: 'PENDING',
  19. context: "jenkins/pr/docs"
  20. }
  21. shell_header = 'export PYENV_ROOT="/usr/local/pyenv"\nexport PATH="$PYENV_ROOT/bin:$PATH"'
  22. } else {
  23. shell_header = ''
  24. }
  25. // Checkout the repo
  26. stage('checkout-scm') {
  27. cleanWs notFailBuild: true
  28. checkout scm
  29. }
  30. // Setup the kitchen required bundle
  31. stage('Setup') {
  32. sh shell_header + '''
  33. eval "$(pyenv init -)"
  34. pyenv --version
  35. pyenv install --skip-existing 2.7.15
  36. pyenv shell 2.7.15
  37. python --version
  38. pip install tox
  39. '''
  40. }
  41. stage('Build') {
  42. sh shell_header + '''
  43. eval "$(pyenv init -)"
  44. pyenv shell 2.7.15
  45. tox -e docs
  46. '''
  47. }
  48. } catch (Exception e) {
  49. currentBuild.result = 'FAILURE'
  50. } finally {
  51. cleanWs notFailBuild: true
  52. if (currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
  53. if (env.NODE_NAME.startsWith('jenkins-pr-')) {
  54. githubNotify credentialsId: 'test-jenkins-credentials',
  55. description: 'The docs job has passed',
  56. status: 'SUCCESS',
  57. context: "jenkins/pr/docs"
  58. }
  59. } else {
  60. if (env.NODE_NAME.startsWith('jenkins-pr-')) {
  61. githubNotify credentialsId: 'test-jenkins-credentials',
  62. description: 'The docs job has failed',
  63. status: 'FAILURE',
  64. context: "jenkins/pr/docs"
  65. }
  66. try {
  67. slackSend channel: "#jenkins-prod-pr",
  68. color: '#FF0000',
  69. message: "FAILED: PR-Job: '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
  70. } catch (Exception e) {
  71. sh 'echo Failed to send the Slack notification'
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. // vim: ft=groovy