1 / 35

Jenkins Pipeline meets Oracle

Learn how to use Jenkins Pipeline to automate APEX application export and deployment in Oracle. This tutorial covers creating a Jenkinsfile, defining stages and steps, using credentials and error handling.

joannam
Télécharger la présentation

Jenkins Pipeline meets Oracle

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. enabling the adaptive enterprise Jenkins Pipeline meets Oracle Oliver Lemm Rotterdam, 26-MAR-2019

  2. Key Facts • Independent Technology Housewith Cross-Industry Expertise Germany‘s number 1 in APEX Branches Frankfurt & Cologne Headquarter Ratingen Oracle Platinum Partner Microsoft Gold Partner 230 employees 33 Mio. Euro Revenue in 2018 • Privately-Owned Corporation Top Company for Trainees & Students Founded 1994

  3. aboutme • Oliver Lemm, Business Unit Leader APEX • Born 1980, married, fourChildren, Place of Residenz Dinslaken • since 2.2007 at the MT AG in Ratingen • Working with APEX since 2007 • Leading in Distribution/Marketing/DeliveryforAPEX Projects • https://apex.mt-ag.com • Doing presentations at DOAG Conference, APEX World, DOAG APEX Connect & ODTUG KScope

  4. Agenda • Introduction in Jenkins • What is a Pipeline • Creating a Pipeline • Jenkinsfile • Moving from Jenkins Jobs to Pipeline • Complex Pipeline • After Jenkins Pipeline

  5. Jenkins https://jenkins.io/

  6. what is Jenkins? “a leightweight tool which is a GUI for your automated processes” “used for continuous integration and continuous delivery” “easy to integrate version control” “free software” “can be compared with gitlab or atlassian bamboo”

  7. keywords in Jenkins … Job“declarative” defined process build stepcalling a batch or running a single http requestone or more build steps are part of a job Buildevery time running a process results in a Build

  8. Demo

  9. using Jenkins in Oracle for … exporting & importing APEX applications generating patchfiles for your application/schema objects using datapump running backend & frontend tests creating users, tablespaces, grants deploying scripts to different databases

  10. what is Pipeline? defining one or multiple jobs in a script Domain Specific Language (DSL) pipeline output

  11. comparing Pipeline vs Job advantages of pipeline are … durable pausable versatile extensible versionable

  12. creating a pipeline (1) new item “pipeline”

  13. creating a pipeline (2)

  14. Jenkinsfile simple example pipeline{ agent {label {label ""customWorkspace"C:/jenkins_projects/cicd" } } stages{ stage('Export APEX App') { steps { withCredentials([usernamePassword(credentialsId: 'db_schema_demo_dev', passwordVariable: 'db_schema_pw', usernameVariable: 'db_schema_user')]) { bat '''cd trunk\\apex ..\\batch\\export_apex_app_sqlcl %db_schema_user% %db_schema_pw% pdb1 %app_id%''' } } } }

  15. Jenkinsfile agent 1) all stages / steps will run on any agent 2) each stage will run on it’s own agent 3) for parallel processes multiple agents can be used and named 4) running jobs in a special workspace the agent should be defined with a customWorkspace 5) using docker you can define different environments based on docker images agent any agent none agent { label “windows” } agent { customWorkspace “c:/Jenkins_projects/cicd” } agent {docker { image “maven:3-alpine” }}

  16. Jenkinsfile stage / stages stages { stage ("Prepare") { ... } stage("PROD - Export App") { ... } stage("PROD - Datapump Export") { ... } stage("Move Dumps") { ... } stage("TEST - Delete Old DB Objects") { ... } stage("TEST - DatapumpImport") { ... } stage("TEST - Import App") {...} } • every pipeline must be defined in stages • every “stages” can have 1-x stage • a stage is a functional bracket • every stage is visible in the Jenkins output

  17. Jenkinsfile step stages{ stage(“run my batch“) {steps { bat '''export_apex_app_sqlcl''' } } } • a step is a technical “bracket” • a step is inside a stage • every stage can have 1-x steps, mostly one stage has 1 step • a step can be a batch or shell or even a plugin callhttps://jenkins.io/doc/pipeline/steps/

  18. Jenkinsfile Snippet Generator

  19. Jenkinsfile credentials • using passwords in a save way • passwords itself are safed encrypted inside Jenkins • credentials are only useable inside the “brackets” • the password ID should be defined and not a random given number • passwords are not readable inside the command line steps { withCredentials([usernamePassword(credentialsId: 'db_schema_demo_dev', passwordVariable: 'db_schema_pw', usernameVariable: 'db_schema_user')]) { bat '''cd trunk\\apex ..\\batch\\export_apex_app_sqlcl %db_schema_user% %db_schema_pw% pdb1 %app_id%''' } }

  20. Credentials database or other technical users

  21. Jenkinsfile errorhandling by stage • searching for error after each stage • setting build “FAILURE”, “UNSTABLE” or “SUCCESS” stage("Create Grants and Synonyms") { steps {bat 'REM Create Grants and Synonyms STARTED' bat '''batch\\create_grants_synonyms'''bat 'REM Create Grants and Synonyms FINISHED' script{ String[] errors = ["ORA-"] checkConsoleOutputAfterBuildStep("Create Grants and Synonyms STARTED", "Create Grants and Synonyms FINISHED", errors, "Create Grants and Synonyms Failed!", "FAILURE") } } }

  22. Jenkinsfile errorhandling by pipeline • Post processing after every stage • Overall one post processing at the end of the pipeline pipeline { stages { stage('do something') { … post {success { bsNotifySuccessful("Set upJobcontrol Environment") } unstable { bsNotifyUnstable("Set upJobcontrol Environment") } aborted { bsNotifyAborted("Set upJobcontrol Environment") } failure { bsNotifyFailed("Set upJobcontrol Environment") } } } post { success { notifySuccessful() } unstable { notifyUnstable() } aborted { notifyAborted() } failure { notifyFailed() } } } }

  23. Jenkinsfile conditional stage(‘conditional by environment') { agent label:'test-node' when { environment name: 'NAME', value: 'this' } steps { echo 'run only if the env name and value matches' } } • running steps by condition • using conditions for environments

  24. Pipeline start from stage

  25. Jenkinsfile • is groovy code • validate code with pipeline Linter

  26. moving from Jobs to Pipeline pipeline starting standard Jenkins jobs pipeline{agent{label{label"„customWorkspace "C:/projects/uit_fpp/svn„ } } stages {stage('110 - Drop Users andTablespaces') {steps {script {defdrop_users_and_tablespaces = buildjob: '110_drop_users_and_tablespaces', parameters: [string(name: 'environment', value: "${params.environment}"), string(name: 'start', value: 'Ja')]currentBuild.result= drop_users_and_tablespaces.result } } }stage('120 - Create Users andTablespaces') { … } }}

  27. Looking into a complex scenario overview DEMO

  28. Looking into a complex scenario logs by stage

  29. Looking into a complex scenario build history, trend and timeline

  30. Conclusion Pipeline is • … more flexible • … code • … versionable • … not declarative any more • … still jenkins pictures by Jenkins.io

  31. and after Pipeline (1) Blue Ocean - https://jenkins.io/projects/blueocean/

  32. and after Pipeline (2) Jenkins X https://jenkins.io/projects/jenkins-x

  33. … after APEX World (1) APEX Migration Workshop - https://apex.mt-ag.com/apex/f?p=276:3

  34. … after APEX World (2) APEX Connect 2019 - https://apex.doag.org

  35. enabling the adaptive enterprise @OliverLemm https://oliverlemm.blogspot.com/ https://www.linkedin.com/in/oliverlemm https://www.xing.com/profile/Oliver_Lemm

More Related