<meta name=" dcterms.product"="">

Oracle by Example branding Automate Updating the Domain with Application Source in a GitHub Repository

section 0Before You Begin

This 20-minute tutorial shows you how to automate updating the domain configuration with WebLogic Deploy Tooling (WDT) artifacts on a public project in Jenkins.

Background

Oracle WebLogic Server for Oracle Cloud Infrastructure Container Engine for Kubernetes (OKE) uses the Jenkins pipeline update domain job to update the domain configuration and deploys applications, shared libraries, and resources to the new domain. In the update domain job, you specify the location of the WDT archive zip file, domain model Yaml and variables properties file using File Upload, Object Storage, or the Shared File System, and build the job.

You can also update the domain configuration using Jenkins Maven project in Oracle WebLogic Server for OKE if you have an application source code and build automation scripts in a git repository. You must have installed Maven before you create a Maven project.

Once you setup the application source code with build and automation scripts in the GitHub repository, you can update the domain configuration by creating a Maven project on Jenkins using source code and then create a pipeline job that triggers the Maven project.

The source code triggers the build system using the GitHub URL and branch name and then copies the WDT archive zip file and model YAML to the shared filed system (/u01/shared), and the pipeline job invokes the Maven project and the existing update domain job in Oracle WebLogic Server for OKE to update the domain configuration.

Then, using these pipeline jobs, you can build the application war or ear file and invoke the Jenkins pipeline update domain job to deploy the application to an Oracle WebLogic Server for OKE instance.

This tutorial offers you the ability to use Oracle WebLogic Server for OKE to update WebLogic domain from an application source in a git repository, and create and run Jenkins pipelines with ready-to-use automation scripts provided by Oracle.

What Do You Need?

  • A stack provisioned using the Resource Manager
  • A GitHub repository with the following files:
  • model directory with model.yaml
  • a sample-app directory that contains:
  • assembly for the maven build
  • wlsdeploy directory that includes web application, sample app, JMS messaging app and the helloworld war file
  • pom.xml

The directory structure is as follows:

                    Directory structure
  • An application source code with build and automation scripts in a GitHub repository

section 1Configure Maven on Jenkins

If you have configured Maven on Jenkins, you can proceed to the next section.

  1. Sign in to the Jenkins console for your domain. See Access the Jenkins Console.
  2. On the Dashboard page, click Manage Jenkins, and then click Global Tool Configuration.
  3. Under Maven, click Add Maven.
  4. Enter a Name for the installation.
  5. Select the Version of Maven to install and click Save.


section 1Create a Maven project Using Source Code Management

  1. Sign in to the Jenkins console for your domain. See Access the Jenkins Console.
  2. On the Dashboard page, click New Item.
  3. Select Maven project from the list of items, and in the Enter an item name field, enter the item name, build_repo , and click Save.
  4. On the Source Code Management tab, for GitHub project, in the Project URL field, enter the git repository URL of the GitHub project that you created. The project URL format is: https://github.com/user/repo.
  5. On the Source Code Management tab, select Git and do the following:
    1. For Repository URL, enter the git repository URL of the GitHub project that you created. For example,  https://gitHub.com/user/repo.
    2. For Branch Specifier, enter the name of the branch (working directory).
  6. On the Build tab, do the following.
    1. For ROOT POM, enter the pom file that you created in GitHub.

      If the pom.xml is not located in the root directory, specify the path.

    2. For example, based on the sample directory structure, the location of the pom file is sample-app/pom.xml.

    3. For Goals and options, enter the goals that you want to execute within this project. Example: clean install.
  7. Click Apply.
  8. On the Dashboard page, click the build_repo job and click Build Now.

    After the job succeeds, you can run the update domain job to pick up the archive zip and model Yaml from workspace folder /u01/shared/var/jenkins_home/jobs/build_repo/workspace location. For practical purposes, the artifacts are not uploaded to a repository.

section 2Create a Pipeline Job Using a Script

    To create this pipeline job, you must provide the pipeline script. This script wraps the build_repo and the update domain jobs in a stage and runs the build. You can view the stages when the job is in progress.

    1. In the Jenkins console, on the Dashboard page, click New Item.
    2. Select Pipeline from the list of items, and in the Enter an item name field, enter the item name, build_repo update domain, and click OK.
    3. On the Advanced Project Options tab, enter the following script:
    4. Note: If your WDT archive file contains the variable properties file, under parameters, you must add Variable_Source and Variable_File_Location. You must update the location of wdt_archive.zip, model.yaml and domain name based on your environment.

      def ARGS = ""
      
      pipeline {
          agent {
              node {
                  label 'agent-label'
              }
          }
          options {
              skipStagesAfterUnstable()
              disableConcurrentBuilds()
              timestamps()
              warnError('Pipeline error caught')
          }
          environment {
              BUILD_TS = getBuildTimestamp()
          }
          stages {
              stage('Build') {
                  steps {
                      build 'build_repo'
                  }
              }
              stage('Update Domain') {
                  steps {
                      build job: 'update domain',
                      parameters: [
                              string(name: 'Archive_File_Location', value: "/u01/shared/archive.zip"),
                              string(name: 'Archive_Source', value:"Shared File System"),
                              string(name: 'Model_File_Location', value: "/u01/shared/model.yaml"),
                              string(name: 'Domain_Model_Source', value:"Shared File System"),
                              string(name: 'Domain_Name', value:"myDomain"),
                              string(name: 'Rollback_On_Failure', value: "true"),
                      ]
                  }
              }
          }
      }
      /**
       * Generating build timestamp.
       * This will be used to tag the updated domain docker image.
      */
      def getBuildTimestamp() {
          Date date = new Date()
          buildTimestamp = date.format('yy-MM-dd_HH-mm-ss')
          println("Generated Build Timestamp: " + buildTimestamp)
          return buildTimestamp
      }
      

    5. Click Apply.
    6. On the Dashboard page, click the build_repo update domain job and click Build Now.


more informationWant to Learn More?



ield