Add Jenkinsfile for the ND pipeline - #519
Draft
astawast-cisco wants to merge 8 commits into
Draft
Conversation
Collaborator
Author
|
The draft PR has been narrowed to the Jenkinsfile only. The duplicated root-level test assets and unrelated .gitignore changes have been removed; the existing integration tests under tests/integration/targets remain the test source. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ND Nightly Pipeline – Combined Draft and Work Done So Far
Summary
This draft combines the existing ND Pipeline1 flow with reliability, security and reporting improvements from my nightly-pipeline work.
Pipeline1 remains the baseline for integration-module coverage, smoke playbooks, repository checkout, dependency installation, linting, fabric reset and Webex presentation.
The proposed additions and enhancements include workspace-local runtime handling, safer Consul downloads, an ND precheck, protected inventory generation, stronger target-level failure handling, cleanup verification, stricter result parsing, artifact collection and direct Webex API delivery.
This is currently a draft for comparison and discussion. The pipeline framework is implemented, but complete end-to-end module execution is pending the testbed-variable fixes documented below.
Baseline retained from Pipeline1
The following capabilities were retained from the existing Pipeline1 flow:
ansible_nd_setupimage.ansible-playbookinvocation per integration target.run_integration_module.yamlrunner.cisco.nddevelopbranch.reset_fabric.yaml.These features were used as the baseline and were extended where required.
Pipeline and Jenkins setup enhancements
The following Jenkins-related changes were incorporated:
Added the nightly schedule.
Added
skipDefaultCheckoutbecause repository checkout is handled explicitly by the pipeline.Added Jenkins timestamps so execution duration and the point of failure are easier to trace.
Added a 30-day retention policy for builds and artifacts.
Retained the ten-hour overall timeout.
Retained protection against concurrent builds because the tests operate on a shared testbed.
Added configurable parameters for:
RUN_SMOKELINT_GATES_BUILDRESET_FABRIC_AFTER_RUNThe
DEBUGparameter is currently reserved and does not yet modify pipeline behaviour.Repository and environment setup
Python 3.12 was already used by Pipeline1. The environment handling was extended as follows:
Added explicit Python 3.12 validation before reusing an existing virtual environment.
Added automatic virtual-environment recreation when the existing environment uses a different Python version.
Moved the virtual environment into the Jenkins workspace:
$WORKSPACE/.jenkins-runtime
Moved the collection checkout into:
$WORKSPACE/nd
Retained checkout of the
cisco.nddevelopbranch.Added explicit comparison of the local and remote commit.
Reused the repository when it is already current.
Re-cloned the repository when the remote branch has changed.
Added validation to ensure an existing
ndpath is a valid Git repository.This reduces dependency on manually maintained files under the Jenkins home directory.
Consul and required pipeline assets
Pipeline1 already downloaded configuration and playbooks from Consul. The download process was strengthened with:
curl --failfor HTTP error handling.The required-file check covers:
requirements.txtrequirements.yamlansible.cfgnd_precheck.yamlnd_cleanup_verify.yamlreset_fabric.yamlrun_integration_module.yamlSmoke playbooks are downloaded only when
RUN_SMOKEis enabled.Dependency installation
The pipeline:
Installs Ansible Core using the supported range:
ansible-core>=2.19,<2.20
Installs Python packages from
requirements.txt.Installs Ansible collections from
requirements.yaml.Validates Python 3.12.
Reports the installed Python version.
Reports the installed Ansible version.
Reports the installed ansible-lint version when available.
A specific ansible-lint version is not currently enforced.
Inventory and credential handling
Pipeline1 already generated an inventory. The combined version changes this to protected JSON inventory generation.
The inventory mechanism:
0600.post/always, including when the build fails.The protected inventory mechanism is implemented, but explicit testbed-value validation and final switch-variable alignment are still pending.
ND precheck
An ND precheck was added before integration and smoke execution.
Its purpose is to detect:
The precheck has a separate ten-minute timeout.
If the precheck fails, integration and smoke targets are not started.
The precheck is implemented but has not yet been validated end to end because the current inventory problem occurs before it can run.
Integration target execution
The currently enabled integration targets are:
nd_manage_policynd_manage_policy_groupnd_manage_networksnd_manage_vrfsnd_vpc_pairPipeline1’s one-invocation-per-target design was retained and extended with:
After target execution begins, a normal failure in one target is recorded and the remaining targets can continue. At the end, failed targets are aggregated and used to update the overall build result.
Failures that occur before the target loop, such as inventory-generation or dependency failures, still prevent all modules from starting.
The five targets are configured, but they have not yet completed an end-to-end run in the combined pipeline.
Cleanup handling
The integration runner retains Pipeline1’s cleanup behaviour:
cleanup.yaml.alwaysblock.The combined pipeline additionally runs:
nd_cleanup_verify.yaml
after every integration target.
This separates two concerns:
Cleanup problems are tracked separately using the
CLEANUP_FAILEDstatus instead of being included as normal module-task failures.Cleanup verification has a separate 15-minute timeout.
Smoke tests
The smoke-playbook list was retained from Pipeline1 and made configurable through
RUN_SMOKE.The smoke coverage includes:
Each smoke playbook has a 45-minute timeout.
Smoke validation is pending. The current focus is to get the integration flow working first.
Ansible exit-code handling
Ansible output is sent through
teeso it can be displayed in Jenkins and saved in the target output file.Without additional handling, a shell pipeline can return the status from
teeinstead of the status fromansible-playbook.The pipeline captures the real Ansible exit code using:
PIPESTATUS[0]
This prevents a successful
teeoperation from hiding an Ansible failure.Failure handling
Target results can use the following statuses:
PASSEDFAILEDUNREACHABLEERRORCLEANUP_FAILEDThe failure-handling flow includes:
Synthetic target failures apply only after
runTarget()starts. Early setup or inventory failures are not currently included in the module counters.Result parsing
The pipeline parses each target’s Ansible PLAY RECAP for:
okfailedskippedunreachableIt also records:
The cleanup verifier produces its own PLAY RECAP. That section is excluded from the integration target’s totals so cleanup tasks do not incorrectly increase the target’s passed count.
The reported
Passedvalue is based on Ansible’sok=count. It therefore represents successful Ansible tasks and not necessarily the number of individual test cases.Artifact collection
Pipeline1 already contained artifact collection. The combined flow keeps target-specific evidence by:
This allows a Webex target result to be traced back to its raw Jenkins and Ansible output.
Artifact creation has not yet been validated end to end because Build 16 did not reach target execution.
Ansible-lint
Pipeline1’s ansible-lint execution was retained and integrated with the new reporting flow.
The combined pipeline:
ansible-lint --profile=production.LINT_GATES_BUILDto control whether lint failures fail the build.There is a known issue where an old
lint_summary.txtcan remain in the workspace when lint does not run. This can result in a currentNOT_RUNstatus being displayed with an older summary.Lint-summary cleanup or conditional display is still pending.
Fabric reset
Pipeline1’s fabric-reset capability was retained and made configurable through:
RESET_FABRIC_AFTER_RUN
The reset stage uses
reset_fabric.yamland the generated inventory.The current Groovy draft defaults this parameter to
true. During validation, it must be manually disabled until the reset playbook and its fabric-specific values have been verified.Before merge, either:
VXLAN_Fabric, orBecause this stage modifies the fabric, it should not be enabled for the nightly run until it has been tested separately.
Webex notification
Pipeline1 already produced Webex notifications. The combined pipeline changes the delivery mechanism to call the Webex API directly instead of downloading and executing a separate notification script.
The implementation:
Once target execution succeeds, the notification is designed to include:
The Webex notification was successfully delivered for Build 16. This confirms that direct API delivery works. Target-level reporting is still pending because Build 16 did not execute any integration target.
Validation completed so far
The following has been completed or validated:
Proposed changes for consideration
The main enhancements proposed for incorporation are:
skipDefaultCheckout.post/always.PIPESTATUS.Next steps