Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

What is jenkins shared library?

  • In short, shared library is the set of common code that you can store in one place and reuse across any Jenkinsfile and github repositories.

  • We can achieve DRY principle by using share libraries

  • For more details, please read this doc - https://www.jenkins.io/doc/book/pipeline/shared-libraries/

Shared library location

Updating shared libraries

  • When updating shared libraries, its not recommended to directly update the changes in the branch

  • This has a large blast radius and can cause all the jenkins jobs to stop working, including adopter jenkins machines

  • As a good practice, a new branch should be created and changes should be tested from this new branch

  • The new branch can be configured on jenkins for a few days to ensure that the changes are working as expected and do not break any flows

  • Once verified, the changes should be merged back to the shared-lib branch so that the community can also get the benefit of these changes

Shared Library Code Reference

List of Shared Library Code

  • All the shared library codes are located here - https://github.com/project-sunbird/sunbird-devops/tree/shared-lib/vars

  • ansible_playbook_run.groovy

    • Clone private repo, copies the inventory to appropriate locations, runs the ansible playbook

  • artifact_download.groovy

    • Downloads provided artifact from cloud storage

  • auto_build_deploy.groovy

    • Used in staging automated deployments to automatically trigger the artifact upload and deploy jobs

  • auto_build_deploy_player.groovy

    • Used in staging automated deployment of Player job to automatically trigger the artifact upload and deploy jobs

  • copy_file_to_wksp.groovy

    • Allows a user to upload a file from Jenkinsjob and copy to workspace

  • deployed_versions.groovy

    • Gives the list of jobs deployed in a release along with the tags (This job needs some enhancement. Currently the data returned is partially correct)

  • docker_params.groovy

    • Used in container workload jenkins job to return information about few parameters to the caller

  • email_notify.groovy

    • Used to send email notifications on the job status

  • lp_dp_params.groovy

    • Used in non-container workload jenkins job to return information about few parameters to the caller

  • pre_checks.groovy

    • Used in automated deployment jenkinsfiles to ensure the tag is an allowed tag for staging environment and the deployment is triggered in the allowed window / slots (start and end time)

  • slack_notify.groovy

    • Used to send slack notifications on the job status

  • stagingRC.groovy

    • Used in staging tag creation jenkinsfile to ensure the tag is an allowed tag for staging environment and the deployment is triggered in the allowed window / slots (start and end time)

  • summary.groovy

    • Used to write the deployed jobs information in a file so that its easy to retrieve the list of deployed jobs in a particular release (this job can be enhanced to provide the data in an enhanced way so that it can be consumed without additional parsing)