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

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

Comments

Loading...