Tuesday, October 13, 2015

Build Automation and Continuous Integration with Oracle SOA Suite 12c: Configuration

Ensure that you have read the Installation post.

In this post, we will configure the requisite software to achieve build automation and continuous configuration.
  • Archiva
  • Maven
  • Git
  • Jenkins

Archiva

During the Archiva configuration, several repositories will be created:

  • EDE - Enterprise Development Environment
  • ITE - Integrated Test Environment
  • IVV - Independent Verification and Validation Environment
  • PRD - Production Environment
  • Mirror - mirror of the Maven Central repository
Each repository will maintain separate copies of Oracle artifacts that may be patched to different versions. For the purpose of the post, we will only populate the EDE environment.

Open a browser, and navigate to http://[host]:8081. You should see the Archiva landing page.
Click Create Admin User.
Provide and confirm the credential and email address. Mark the Validated checkbox. Click Save.

In the left navigation area, click Repositories. Click Add.
Add the following repositories:
  • id: mirror
  • name: Mirror of Central
  • directory: ./repositories/mirror
  • releases: true
  • scanned: true
  • id: ede
  • name: Enterprise Development Environment
  • directory: ./repositories/ede
  • releases: true
  • scanned: true
  • id: ite
  • name: Integrated Test Environment
  • directory: ./repositories/ite
  • releases: true
  • scanned: true
  • id: ivv
  • name: Independent Verification and Validation Environment
  • directory: ./repositories/ivv
  • releases: true
  • scanned: true
  • id: prd
  • name: Production Environment
  • directory: ./repositories/prd
  • releases: true
  • scanned: true
In the left navigation area, click Proxy Connectors. Delete the internal-central proxy connector.
Click Ok to confirm.
Click Add.
Select mirror as the Managed Repository and central as the Remote Repository. Click Save.

In the left navigation, click Manage. Click Add.
Add the following users:

  • This user has access to the EDE repository.
  • username: edeuser
  • password: [edeUserPassword]
  • email: [edeUserEmailAddress]
  • validated: true
  • This user has access to the ITE repository.
  • username: iteuser
  • password: [iteUserPassword]
  • email: [iteUserEmailAddress]
  • validated: true
  • This user has access to the IVV repository.
  • username: ivvuser
  • password: [ivvUserPassword]
  • email: [ivvUserEmailAddress]
  • validated: true
  • This user has access to the PRD repository.
  • username: prduser
  • password: [prdUserPassword]
  • email: [prdUserEmailAddress]
  • validated: true
  • This user has access to the Snapshots repository.
  • username: snapshotuser
  • password: [snapshotUserPassword]
  • email: [snapshotUserEmailAddress]
  • validated: true
  • This user has access to all repositories and will be used by Hudson to deploy builds.
  • username: deployer
  • password: [deployerPassword]
  • email: [deployerEmailAddress]
  • validated: true

Edit the edeuser.
Click Edit Roles.
Grant the following permissions on the repositories:
  • mirror: Repository Observer
  • [ede|ite|ivv|prd|snapshots]: Repository Manager
Edit the remaining users substituting the repository, e.g. iteuser ~ ite repository.

Grant Global Repository Observer to the deployer user.

Grant Repository Observer access to the guest user for each repository.


Maven

Maven uses two settings files for operational purposes:
  1. settings-security.xml, and
  2. settings.xml.
These files contain clear-text credentials that are used to authenticate with Archiva. Luckily, Maven has the ability to encrypt these credentials so that they are not easily distinguished.

Login as the oracle user.

mvn --encrypt-master-password welcome1
{JE0mp1G1u14HE35kTBWCjQQjoSm5BK9QNgO6nwqWOng=}

Copy/paste this encrypted credential into the settings-security.xml file.

vi /home/oracle/.m2/settings-security.xml

<settingsSecurity>
        <master>encryptedCredential</master>
</settingsSecurity>

Next, encrypt the passwords for the repository users that were created earlier, i.e. edeuser, iteuser, etc. Store these credentials temporarily - they will be persisted in the Maven settings.xml file in just a second.

mvn --encrypt-password [edeUserPassword|iteUserPassword|ivvUserPassword|pdrUserPassword]

Next, the settings.xml file will need modified to point to the repositories created in Archiva. The following Maven settings file uses several profiles with activation properties. Refer to the Maven Settings Reference for more information. Notice the <localRepository> element that points to the Maven repository.

vi /home/oracle/.m2/settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/ci/repository</localRepository>
<servers>
   <server>
       <id>ede</id>
       <username>edeuser</username>
       <password>{94Qd2IJWYmMHRSZn081ROtkFv4+ZM5JHe63rNZQXWCk=}</password>
   </server>
   <server>
       <id>ite</id>
       <username>iteuser</username>
       <password>{10a8rTZBTI8HuKmK+NKaFp449LAmLMom0DA43f8/G4U=}</password>
   </server>
   <server>
       <id>ivv</id>
       <username>ivvuser</username>
       <password>{WTOOUq91QXAHZn/vP07j5iptExrycQjYwmU4zS7Sf78=}</password>
   </server>
   <server>
       <id>prd</id>
       <username>prduser</username>
       <password>{2LjH6G9SDSYHaVzP9c5Rndp7CdLK/0pVtJ6owXp3Meg=}</password>
   </server>
  <server>
       <id>snapshots</id>
       <username>snapshotuser</username>
       <password>{iaXW4L9fgs0HeOnorqOubdfj7UkUNYvp+UCQJhMiLmI=}</password>
   </server>
</servers>
<mirrors>
   <mirror>
       <id>mirror</id>
       <name>Mirror of Central</name>
       <url>http://ci:8081/repository/mirror</url>
       <mirrorOf>central</mirrorOf>
   </mirror>
</mirrors>
<profiles>
   <profile>
       <id>ede</id>
<activation>
            <property>
                <name>env</name>
                <value>ede</value>
            </property>
        </activation>
       <repositories>
           <repository>
               <id>ede</id>
               <name>Enterprise Development Environment Repository</name>
               <url>http://ci:8081/repository/ede</url>
               <layout>default</layout>
               <releases>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
                   <checksumPolicy>warn</checksumPolicy>
               </releases>
               <snapshots>
                   <enabled>false</enabled>
                   <updatePolicy>never</updatePolicy>
                   <checksumPolicy>fail</checksumPolicy>
               </snapshots>
           </repository>
           <repository>
               <id>snapshots</id>
               <name>Archiva Managed Snapshot Repository</name>
               <url>http://ci:8081/repository/snapshots</url>
               <layout>default</layout>
               <releases>
                   <enabled>false</enabled>
                   <updatePolicy>never</updatePolicy>
                   <checksumPolicy>fail</checksumPolicy>
               </releases>
               <snapshots>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
                   <checksumPolicy>warn</checksumPolicy>
               </snapshots>
           </repository>
           <repository>
            <id>central</id>
               <name>Central Repository</name>
               <url>http://ci:8081/repository/mirror</url>
           </repository>
       </repositories>
       <pluginRepositories>
        <pluginRepository>
        <id>ede</id>
            <name>Enterprise Development Environment Plug-in Repository</name>
            <url>http://ci:8081/repository/ede</url>
            <releases>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
                   <checksumPolicy>warn</checksumPolicy>
               </releases>
               <snapshots>
                   <enabled>false</enabled>
                   <updatePolicy>never</updatePolicy>
                   <checksumPolicy>fail</checksumPolicy>
               </snapshots>
        </pluginRepository>
        <pluginRepository>
        <id>central</id>
            <name>Central Plug-in Repository</name>
            <url>http://ci:8081/repository/mirror</url>
            <releases>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
                   <checksumPolicy>warn</checksumPolicy>
               </releases>
               <snapshots>
                   <enabled>false</enabled>
                   <updatePolicy>never</updatePolicy>
                   <checksumPolicy>fail</checksumPolicy>
               </snapshots>
        </pluginRepository>
       </pluginRepositories>
   </profile>
   <profile>
    <id>ite</id>
    <activation>
            <property>
                <name>env</name>
                <value>ite</value>
            </property>
        </activation>
    <repositories>
    <repository>
               <id>ite</id>
               <name>Integrated Test Environment Repository</name>
               <url>http://ci:8081/repository/ite</url>
               <layout>default</layout>
               <releases>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
                   <checksumPolicy>warn</checksumPolicy>
               </releases>
               <snapshots>
                   <enabled>false</enabled>
                   <updatePolicy>never</updatePolicy>
                   <checksumPolicy>fail</checksumPolicy>
               </snapshots>
           </repository>
<repository>
            <id>central</id>
               <name>Central Repository</name>
               <url>http://ci:8081/repository/mirror</url>
           </repository>
       </repositories>
      <pluginRepositories>
        <pluginRepository>
        <id>ite</id>
            <name>Integrated Test Environment Plug-in Repository</name>
            <url>http://ci:8081/repository/ite</url>
        </pluginRepository>
        <pluginRepository>
        <id>central</id>
            <name>Central Plug-in Repository</name>
            <url>http://ci:8081/repository/mirror</url>
        </pluginRepository>
       </pluginRepositories>
  </profile>
  <profile>
  <id>ivv</id>
  <activation>
            <property>
                <name>env</name>
                <value>ivv</value>
            </property>
        </activation>
  <repositories>
  <repository>
               <id>ivv</id>
               <name>Independent Verification and Validation Repository</name>
               <url>http://ci:8081/repository/ivv</url>
               <layout>default</layout>
               <releases>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
                   <checksumPolicy>warn</checksumPolicy>
               </releases>
               <snapshots>
                   <enabled>false</enabled>
                   <updatePolicy>never</updatePolicy>
                   <checksumPolicy>fail</checksumPolicy>
               </snapshots>
           </repository>
           <repository>
            <id>central</id>
               <name>Central Repository</name>
               <url>http://ci:8081/repository/mirror</url>
           </repository>
       </repositories>
<pluginRepositories>
        <pluginRepository>
        <id>ivv</id>
            <name>Independent Verification and Validation Plug-in Repository</name>
            <url>http://ci:8081/repository/ivv</url>
        </pluginRepository>
        <pluginRepository>
        <id>central</id>
            <name>Central Plug-in Repository</name>
            <url>http://ci:8081/repository/mirror</url>
        </pluginRepository>
       </pluginRepositories>
  </profile>
  <profile>
  <id>prd</id>
  <activation>
            <property>
                <name>env</name>
                <value>prd</value>
            </property>
        </activation>
  <repositories>
  <repository>
               <id>prd</id>
               <name>Production Repository</name>
               <url>http://ci:8081/repository/prd</url>
               <layout>default</layout>
               <releases>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
                   <checksumPolicy>warn</checksumPolicy>
               </releases>
               <snapshots>
                   <enabled>false</enabled>
                   <updatePolicy>never</updatePolicy>
                   <checksumPolicy>fail</checksumPolicy>
               </snapshots>
           </repository>
           <repository>
            <id>central</id>
               <name>Central Repository</name>
               <url>http://ci:8081/repository/mirror</url>
           </repository>
       </repositories>
<pluginRepositories>
        <pluginRepository>
        <id>prd</id>
            <name>Production Plug-in Repository</name>
            <url>http://ci:8081/repository/prd</url>
        </pluginRepository>
        <pluginRepository>
        <id>central</id>
            <name>Central Plug-in Repository</name>
            <url>http://ci:8081/repository/mirror</url>
        </pluginRepository>
       </pluginRepositories>
  </profile>
</profiles>
<activeProfiles>
<activeProfile>ede</activeProfile>
</activeProfiles>
</settings>

Login as the root user.

Create the repository directory.

mkdir -p /ci/repository
chown oracle:oinstall /ci/repository
chmod 755 /ci/repository

Git

Login as the oracle user.

Create a repository to store source code.

mkdir -p /ci/git/
cd /ci/git
git clone --bare demo.git
Initialized empty Git repository in /ci/git/demo.git/
warning: You appear to have cloned an empty repository.

Clone the Git repository from ssh://oracle@[host]/ci/git/demo.git using your chosen Git client - SourceTree, GitHub Desktop, etc.

Create a post-commit hook to trigger a Jenkins build when a push to the repository occurs.

Navigate to the Git repository /hooks directory.

cd /ci/git/demo.git/hooks

vi post-commit


#!/bin/sh
#
# A hook to trigger a build when a push to the repository occurs 
#

curl http://[host]:8080/git/notifyCommit?url=file:///ci/git/demo.git 

Jenkins

Open a browser, and navigate to the Jenkins URL - http://[host]:8080

Click Jenkins, and then, click Manage Jenkins.


Click Enable Security.

Mark the Enable security checkbox. Mark the Jenkins' own security database radio button. Mark the Allow users to sign up checkbox. Mark the Matrix-based security radio button. Add an admin user. In the permission table to the far right, click the Select All image to highlight all the checkboxes. Click Save.

Click Signup and create the admin user.

Click Manage Jenkins >> Manage Plugins.

Mark all of the checkboxes for currently installed plugins to update them.

Click the Available tab.
Install the following plugins, and click the Download now and install after reboot button.
  • GIT plugin
  • Config File Provider Plugin
Mark the Restart Jenkins when installation is complete and no jobs are running checkbox.

After Jenkins restarts, click Manage Jenkins >> Configure System.

Jenkins needs to be made aware of the $ORACLE_HOME so that the deploy goal can invoke JDeveloper ojdeploy. In the Global Properties section, mark the Environment variables checkbox. Provide the following variable:
  • Name: ORACLE_HOME
  • Value: /u01/fmw


Click Add JDK.

Provide the JDK name. Unmark install automatically. Provide the path to the JDK home.

Click Add Maven.

Provide the Maven name. Unmark install automatically. Provide the path to the Maven home.

Click Save.

Click Manage Jenkins >> Managed Files.

Click Add a new Config.

Mark the Maven settings.xml radio button. Click Submit.

Provide a name and comment for the config file. Paste the contents of settings.xml detailed in the Maven section above. Click Submit.

Return to the Configure System page (Manage Jenkins >> Configure System). In the Maven Configuration section, Default settings provider dropdown, select provided settings.xml. In the Provided settings dropdown, select the settings file created a moment ago.

Click Save.

References:
Oracle® Fusion Middleware Developing Applications Using Continuous Integration
Maven Settings Reference

No comments:

Post a Comment