Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Jenkinsfile 4.0 KB

You have to be logged in to leave a comment. Sign In
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
  1. /* groovylint-disable CompileStatic, DuplicateMapLiteral, DuplicateStringLiteral, LineLength, NestedBlockDepth */
  2. pipeline {
  3. agent any
  4. environment {
  5. GIT_COMMIT_REV = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
  6. // GIT_COMMIT_MASTER = sh(returnStdout: true, script: 'git rev-parse --short master').trim()
  7. }
  8. stages {
  9. stage('Run inside Docker Image') {
  10. agent {
  11. dockerfile {
  12. args "-v ${env.WORKSPACE}:/project -w /project -v /extras:/extras -e PYTHONPATH=/project"
  13. }
  14. }
  15. stages {
  16. stage('Run Unit Test') {
  17. steps {
  18. sh 'pytest -vvrxXs'
  19. }
  20. }
  21. stage('Run Linting') {
  22. steps {
  23. sh '''
  24. flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
  25. flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
  26. black . --check --diff
  27. '''
  28. }
  29. }
  30. stage('Setup DVC Creds') {
  31. steps {
  32. withCredentials(
  33. [
  34. usernamePassword(
  35. credentialsId: 'PASSWORD',
  36. passwordVariable: 'PASSWORD',
  37. usernameVariable: 'USER_NAME'),
  38. ]
  39. ) {
  40. sh '''
  41. dvc remote modify origin --local auth basic
  42. dvc remote modify origin --local user $USER_NAME
  43. dvc remote modify origin --local password $PASSWORD
  44. dvc pull -r origin
  45. '''
  46. }
  47. }
  48. }
  49. stage('Sync DVC Remotes') {
  50. steps {
  51. sh '''
  52. dvc status
  53. dvc status -r jenkins_local
  54. dvc status -r origin
  55. dvc pull -r jenkins_local || echo 'Some files are missing in local cache!'
  56. dvc pull -r origin
  57. dvc push -r jenkins_local
  58. '''
  59. }
  60. }
  61. stage('Update DVC Pipeline') {
  62. when { changeRequest() }
  63. steps {
  64. sh '''
  65. dvc repro --dry -mP
  66. dvc repro -mP
  67. git branch -a
  68. cat dvc.lock
  69. dvc push -r jenkins_local
  70. dvc push -r origin
  71. rm -r /extras/RPPP/repo/$CHANGE_BRANCH || echo 'All clean'
  72. mkdir -p /extras/RPPP/repo/$CHANGE_BRANCH
  73. cp -Rf . /extras/RPPP/repo/$CHANGE_BRANCH
  74. '''
  75. sh 'dvc metrics diff --show-md --precision 2 $CHANGE_TARGET'
  76. }
  77. }
  78. }
  79. }
  80. stage('Commit back results') {
  81. when { changeRequest() }
  82. steps {
  83. dir("/extras/RPPP/repo/${env.CHANGE_BRANCH}") {
  84. sh '''
  85. git branch -a
  86. git status
  87. if ! git diff --exit-code; then
  88. git add .
  89. git status
  90. git commit -m '$GIT_COMMIT_REV: Update dvc.lock and metrics'
  91. git push origin HEAD:$CHANGE_BRANCH
  92. else
  93. echo 'Nothing to Commit!'
  94. fi
  95. '''
  96. }
  97. }
  98. }
  99. }
  100. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...