Import mechanism in (git) jobs #643
-
Hello, I have several questions / remarks about the import abilities in (git) jobs. The documentation states that the directory must contains a This was noticed because I have multiple jobs reusing the same functions so I decided to put them in a I also tested something like:
without success. So the questions are:
And a bit off-topic, when using test-only job, the log info [1]: If you want an import ASCII order reproduction, create the following files:
Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Nobody ? To continue in the Jobs mechanics, Using |
Beta Was this translation helpful? Give feedback.
-
Thank you for the question! The Git repository Job discovery implementation, much like the I'll state that from my viewpoint, if there's enough complexity in your Jobs that you need to have a common "library" of code to be used across multiple Jobs, my general recommendation would be to package the library code (at least) into a Python package and/or a Nautobot plugin so that it all can take advantage of the standard Python packaging and source code discovery capabilities. You could include the Jobs themselves in this plugin as well (if they are not expected to change frequently and hence require re-installation when updated) or keep them separately in the Git repository (if they're actively being updated and you want the ease-of-use of being able to reload them on-the-fly from Git). I'll reply to your follow-up questions in a separate post when I have some more time. Thanks again! |
Beta Was this translation helpful? Give feedback.
-
A bit late, but thank you for your replies! In the end, the code about Nautobot (jobs, config context schemas) was separated in it's own repository (to avoid repeating the code for multiple infras) and the Gitlab is used to host the code, so to avoid manual sync, a pipeline was added to list the repos and if the slug+branch match, call the For the |
Beta Was this translation helpful? Give feedback.
Thank you for the question!
The Git repository Job discovery implementation, much like the
$JOBS_ROOT
Job discovery, is really designed more around importing individual files in isolation - as you've seen here, while it may be possible to work around this, it's definitely outside the scope of how the feature is "intended" to be used. We could probably stand to improve the documentation and recommendations here to make this more explicit.I'll state that from my viewpoint, if there's enough complexity in your Jobs that you need to have a common "library" of code to be used across multiple Jobs, my general recommendation would be to package the library code (at least) into a Python package …