CI/CD for Oracle Database & APEX Developers
Total Page:16
File Type:pdf, Size:1020Kb
CI/CD for Oracle Database & APEX Developers RMOUG Virtual Training Days 2021 Brian Spendolini Product Manager Oracle Database Development Tools @btspendo btspendo https://blogs.oracle.com What is CI/CD? 2 Copyright © 2020, Oracle and/or its affiliates What is CI/CD and Why do we need it? CI/CD is continuous integration, continuous delivery, and continuous deployment • Introduces automation into all stages of app/database development • Helps developers work on the same app and merge their code changes back to a shared branch frequently • Development changes are automatically tested on push/commits and merges Why? • Consistency/Repeatability • Accountability • Security • Standardization • Find Issues Faster/Better Code/Quality Releases • More Frequent Releases 3 Copyright © 2020, Oracle and/or its affiliates CI/CD with the database and APEX? Traditionality this has been hard. Why? • APEX/DB bucks the trend of isolated development environments • Dev instances can be expensive • Licensing issues • DB/APEX changes are different from traditional files/code seen with DevOPs and CI/CD processes • Metadata driven • Versioning or lack there of • Rollback issues • Very manual process and a lot of individual accountability • DB change tracking • APEX change tracking • Isn't DevOps for those new-fangled development languages only? 4 Copyright © 2020, Oracle and/or its affiliates CI/CD with the database and APEX? We can fix it? Yes, we can! Centralized code repository no more big zips or wiki pages with attachments Individual code branches Individual development environments Easy change tracking creating scripts is not fun Embrace the cloud Autonomous Database uses per-second billing ADB’s can cost less than $35 a day 5 Copyright © 2020, Oracle and/or its affiliates CI/CD with the database and APEX? What tools do I need? • Git/code repository • SQLcl/Liquibase • VS Code/SQL Developer • utPLSQL • Terraform • OCI account (free/paid) • Jenkins 6 Copyright © 2020, Oracle and/or its affiliates SQLcl and Liquibase What’s SQLcl? Oracle SQLcl (SQL Developer Command Line) is a Java-based command-line interface for Oracle Database. Using SQLcl, you can execute SQL and PL/SQL statements interactively or as as a batch file. SQLcl provides inline editing, statement completion, command recall, and also supports existing SQL*Plus scripts. What’s Liquibase? Liquibase is an open-source database-independent library for tracking, managing and applying database schema changes. How do they work together? The Liquibase feature in SQLcl enables you to execute commands to generate a changelog for a single object or for a full schema (changeset and changelogs). 7 Copyright © 2020, Oracle and/or its affiliates Terraform and OCI • Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. • Think Infrastructure as code • Full set of APIs/Resources for OCI via Terraform • https://registry.terraform.io/providers/hashicorp/oci/latest/docs • Create and Destroy OCI resources quickly and consistently • Similar to OCI CLI resource "oci_database_autonomous_database" "new_autonomous_database" { #Required compartment_id = var.compartment_ocid cpu_core_count = "1" data_storage_size_in_tbs = "1" db_name = "TESTDB${random_string.db_name.result}" admin_password = random_string.password.result db_workload = "OLTP" display_name = "TESTDB${random_string.db_name.result}" } 8 Copyright © 2020, Oracle and/or its affiliates Sample Environment What’s a sample environment look like for CI/CD with the Autonomous database and OCI? OCI OCI Resources can be created via instance Github principles for the CI/CD process Virtual Cloud Network Code Autonomous Database Repository Public Subnet Internet Compute VM Gateway with Jenkins OCI Resources Jenkins Load Webhook Compute SQLcl Balancer Git Terraform Object Store Network Developers Created on demand via Terraform 9 Copyright © 2020, Oracle and/or its affiliates The Development Process Putting it all together 10 Copyright © 2020, Oracle and/or its affiliates The Flow Start Sprint Create Individual Create Developer Dev Branches in git Environments 11 Copyright © 2020, Oracle and/or its affiliates Individual Environments and Creation Individual environments need: • APEX (Apps and workspace) • DB Schema(s) • Code from the repository (latest) or deployment Utilize the autonomous database/multitenancy • Clone features • Three PDBs for free in 19c Automate the process with APIs • OCI CLI • PLSQL SDK • ORDS and the SQL Endpoint • Terraform 12 Copyright © 2020, Oracle and/or its affiliates Demo: ADB cloning/APEX app 13 Copyright © 2020, Oracle and/or its affiliates Central Code Repository Choose your repository but choose it and use it! • git • github • gitlab • Bitbucket Get familiar with using it every day • Push often • Integrate it into your daily workflow • Individual branches for each developer Many tools have it built in! • SQL Developer • VS Code 14 Copyright © 2020, Oracle and/or its affiliates Demo: github and Vscode integration 15 Copyright © 2020, Oracle and/or its affiliates The Flow Development Start Sprint Phase Create Individual DB/App Create Developer CI Process for Dev Change Branches in git code pushes Environments Tracking 16 Copyright © 2020, Oracle and/or its affiliates Change Management with APEX and the Database SQLcl and Liquibase • Exporting of the APEX app -expOriginalIds • Exporting of the schema objects with LB Code Reviews before merges/pulls Releases • Be aware of the difference between git/gitlab/github 17 Copyright © 2020, Oracle and/or its affiliates Demo: SQLcl and LB 18 Copyright © 2020, Oracle and/or its affiliates CI Process for code pushes Every code push/pull/merge should spawn a CI/CD pipeline (webhooks) The pipeline should • Clone from the development environment • Apply the developers branch/merged main into that database • Run unit tests • Report back on the status of the pipeline • Destroy the environment if it is successful/Keep it running if not successful 19 Copyright © 2020, Oracle and/or its affiliates Demo: Jenkins and pipeline 20 Copyright © 2020, Oracle and/or its affiliates The Flow Development Start Sprint Deployment Phase Create Individual DB/App Create Developer CI Process for Automate Dev Change Choose Target Branches in git code pushes Process Environments Tracking 21 Copyright © 2020, Oracle and/or its affiliates Deployment Targets and Automating the Process • Pipelines can also be scheduled or started manually • Choose deployment target with pipelines • Deploy Manually • Zip up the repo and deploy when you want • Eliminate surprises by having a logical progression of environments • Dev • UAT • Production • Use ADB/DB clones to practice deployments manually or via pipelines 22 Copyright © 2020, Oracle and/or its affiliates The Flow Development Start Sprint Deployment Phase Create Individual DB/App Create Developer CI Process for Automate Dev Change Choose Target Branches in git code pushes Process Environments Tracking 23 Copyright © 2020, Oracle and/or its affiliates Next Steps Where do we go from here? 24 Copyright © 2020, Oracle and/or its affiliates Next Steps Go Slow Cultivate an environment that encourages CI/CD Incorporate pieces/adopt what works for you and your teams All code is hosted in github (devops folder) https://github.com/oracle/oracle-db-tools Any issues let us know and the projects will be updated on a regular basis Oracle LiveLabs https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/home Demos and Labs to get you started in OCI and with the Oracle database 25 Copyright © 2020, Oracle and/or its affiliates Next Steps Upcoming Web Series All things Developer with the Oracle Database and CI/CD Reach out directly Let us know about your journey and any issues/enhansments you would like to see @btspendo on Twitter 26 Copyright © 2020, Oracle and/or its affiliates 27 Copyright © 2020, Oracle and/or its affiliates .