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.5 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
101
102
103
104
105
106
107
  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. JENKINS_USER_NAME = 'JenkinsRPPP'
  7. JENKINS_EMAIL = 'jenkins@rppp.com'
  8. }
  9. stages {
  10. stage('Run inside Docker Image') {
  11. agent {
  12. dockerfile {
  13. args "-v ${env.WORKSPACE}:/project -w /project -v /extras:/extras -e PYTHONPATH=/project"
  14. }
  15. }
  16. stages {
  17. stage('Run Unit Test') {
  18. steps {
  19. sh 'pytest -vvrxXs'
  20. }
  21. }
  22. stage('Run Linting') {
  23. steps {
  24. sh '''
  25. flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
  26. flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
  27. black . --check --diff
  28. '''
  29. }
  30. }
  31. stage('Setup DVC Creds') {
  32. steps {
  33. withCredentials(
  34. [
  35. usernamePassword(
  36. credentialsId: 'PASSWORD',
  37. passwordVariable: 'PASSWORD',
  38. usernameVariable: 'USER_NAME'),
  39. ]
  40. ) {
  41. sh '''
  42. dvc remote modify origin --local auth basic
  43. dvc remote modify origin --local user $USER_NAME
  44. dvc remote modify origin --local password $PASSWORD
  45. dvc status -r origin
  46. '''
  47. }
  48. }
  49. }
  50. stage('Sync DVC Remotes') {
  51. steps {
  52. sh '''
  53. dvc status
  54. dvc status -r jenkins_local
  55. dvc status -r origin
  56. dvc pull -r jenkins_local || echo 'Some files are missing in local cache!'
  57. dvc pull -r origin
  58. dvc push -r jenkins_local
  59. '''
  60. }
  61. }
  62. stage('Update DVC Pipeline') {
  63. when { changeRequest() }
  64. steps {
  65. sh '''
  66. dvc repro --dry -mP
  67. dvc repro -mP
  68. git branch -a
  69. cat dvc.lock
  70. dvc push -r jenkins_local
  71. dvc push -r origin
  72. '''
  73. sh 'dvc metrics diff --show-md --precision 2 $CHANGE_TARGET'
  74. }
  75. }
  76. stage('Commit back results') {
  77. when { changeRequest() }
  78. steps {
  79. withCredentials(
  80. [
  81. usernamePassword(
  82. credentialsId: 'GIT_PAT',
  83. passwordVariable: 'GIT_PAT',
  84. usernameVariable: 'GIT_USER_NAME'),
  85. ]
  86. ) {
  87. sh '''
  88. git branch -a
  89. git status
  90. if ! git diff --exit-code dvc.lock; then
  91. git add .
  92. git status
  93. git config --local user.email $JENKINS_EMAIL
  94. git config --local user.name $JENKINS_USER_NAME
  95. git commit -m "$GIT_COMMIT_REV: Update dvc.lock and metrics"
  96. git push https://$GIT_USER_NAME:$GIT_PAT@github.com/PuneethaPai/RPPP HEAD:$CHANGE_BRANCH
  97. else
  98. echo 'Nothing to Commit!'
  99. fi
  100. '''
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
Tip!

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

Comments

Loading...