Thursday, December 31, 2020

Call another job in Jenkins declarative pipeline with parameters

 HOWTO

 

Parameters on the pipeline job

pipeline {
    agent any
    parameters {
        string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')

        text(name: 'BIOGRAPHY', defaultValue: '', description: 'Enter some information about the person')

        booleanParam(name: 'TOGGLE', defaultValue: true, description: 'Toggle this value')

        choice(name: 'CHOICE', choices: ['One', 'Two', 'Three'], description: 'Pick something')

        password(name: 'PASSWORD', defaultValue: 'SECRET', description: 'Enter a password')
    }
    stages {
        stage('Example') {
            steps {
                echo "Hello ${params.PERSON}"

                echo "Biography: ${params.BIOGRAPHY}"

                echo "Toggle: ${params.TOGGLE}"

                echo "Choice: ${params.CHOICE}"

                echo "Password: ${params.PASSWORD}"
            }
        }
    }
}

 

Called job


pipeline {
    agent { 
       label 'dave_node'
    }
    parameters {
        string(name: 'branch', defaultValue: 'main', description: 'Some branch')
    }
    stages {
        stage('CalledJob') {
        
            steps {
            
                 echo "Build CalledJob branch ${params.branch}"  
                 
                 script {         
                     params.each {param ->
                       println "${param.key} -> ${param.value} "
                     }
                 }
                         
            
                git url: 'https://github.com/dveselka/calledjob/', credentialsId: 'daveCredentials', branch: "${params.branch}"     
            }
        }
    }
}


Calling job

   
       stage('BuildOtherJob') {
            steps {   
            
            echo "Call other job job"        
                script {           
                      build job: 'jobtocall', parameters: [
                             string(name: 'branch', value: "some_branch")
                        ]
                }
            }
       }    


Dynamic agent

pipeline {
    agent { 
       label params.agent == null || params.agent.isEmpty() ? "default-agent" : params.agent
    }

Sunday, December 27, 2020

Deploy JBoss Wildfly Java EE app with Maven using Jenkins pipeline and Docker

 HOWTO

 

GitHub projects


Pipeline file https://github.com/dveselka/java-ee-8/blob/main/java-ee8-minimal/Jenkinsfile

Add jenkins user into docker group

sudo usermod -aG docker jenkins
sudo systemctl restart jenkins

Checkout app from GitHub

        stage('Checkout') {
          git url: 'https://github.com/dveselka/java-ee-8/', credentialsId: 'dave-devops', branch: 'main'
        }

 

Build application using Maven

        stage('Build') {
          
          dir('java-ee8-minimal'){
             withMaven(maven:'Maven'
             ) {
                sh 'pwd'
                sh 'env'
                sh 'mvn clean package'
            
                def pom = readMavenPom file:'pom.xml'
                print pom.version
                env.version = pom.version
             }
          }
        }

 

Build Docker image

https://www.jenkins.io/doc/book/pipeline/docker/
        stage("BuildDockerImage"){
          dir('java-ee8-minimal'){
            def customImage = docker.build("my-image:${env.BUILD_ID}")
          }
        }
Jenkins log - Docker image build
[Pipeline] { (Image)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/java-ee-8/java-ee8-minimal
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker build -t com.dave/java-ee8-minimal:4 .
Sending build context to Docker daemon  46.59kB

Step 1/4 : FROM jboss/wildfly
 ---> 8d9094a2468d
Step 2/4 : RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent
 ---> Using cache
 ---> 8b8272a09327
Step 3/4 : COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/
 ---> 229ba08da529
Step 4/4 : CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
 ---> Running in fdea8bab71ee
Removing intermediate container fdea8bab71ee
 ---> c165d87af41e
Successfully built c165d87af41e
Successfully tagged com.dave/java-ee8-minimal:4

 

Push Docker image to repository (optional)

 

Run container

        stage ('Run') {
          dir('java-ee8-minimal'){
            docker.image("com.dave/java-ee8-minimal:${env.BUILD_ID}").run('-it --name java-ee8-minimal com.dave/java-ee8-minimal')
          }
        }

 

Install Jenkins Docker plugin to remove this error

groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding
    at groovy.lang.Binding.getVariable(Binding.java:63)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:270)

 
Jenkins log - run Docker container

[Pipeline] { (Run)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/java-ee-8/java-ee8-minimal
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker run -d -it --name java-ee8-minimal com.dave/java-ee8-minimal:6
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
Docker process
docker ps -a
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS               NAMES
0eb3d2588c6b        com.dave/java-ee8-minimal:6   "/opt/jboss/wildfly/…"   2 minutes ago       Up 2 minutes        8080/tcp            java-ee8-minimal

Deploy Java EE 8 application into JBoss Wildfy AS running on Docker

HOWTO

 

GitHub projects

Start JBoss Wildfly using Docker

[dave@dave java-ee-8]$ docker run -it jboss/wildfly
Unable to find image 'jboss/wildfly:latest' locally
latest: Pulling from jboss/wildfly
75f829a71a1c: Pull complete 
7b11f246b3d3: Pull complete 
b765648c2a58: Pull complete 
506aff4a9c5a: Pull complete 
e7e0b6e22530: Pull complete 
Digest: sha256:152a4dd6e524afa133dd200b1a4ba6411dc334dfd84921d5eafcbae85f859c00
Status: Downloaded newer image for jboss/wildfly:latest
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED

=========================================================================

10:40:59,521 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.2.Final
10:41:00,013 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.12.Final
10:41:00,021 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final
10:41:00,093 WARN  [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended
10:41:00,133 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) starting
10:41:00,961 INFO  [org.wildfly.security] (ServerService Thread Pool -- 27) ELY00001: WildFly Elytron version 1.13.1.Final
10:41:01,501 INFO  [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
10:41:01,542 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 36) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
10:41:01,611 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
10:41:01,626 INFO  [org.xnio] (MSC service thread 1-5) XNIO version 3.8.2.Final
10:41:01,631 INFO  [org.xnio.nio] (MSC service thread 1-5) XNIO NIO Implementation Version 3.8.2.Final
10:41:01,671 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 52) WFLYCLINF0001: Activating Infinispan subsystem.
10:41:01,685 INFO  [org.wildfly.extension.microprofile.jwt.smallrye._private] (ServerService Thread Pool -- 63) WFLYJWT0001: Activating WildFly MicroProfile JWT Subsystem
10:41:01,693 INFO  [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 61) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
10:41:01,700 INFO  [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 5.0.19.Final
10:41:01,709 INFO  [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 62) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
10:41:01,711 INFO  [org.jboss.as.jaxrs] (ServerService Thread Pool -- 54) WFLYRS0016: RESTEasy version 3.13.2.Final
10:41:01,718 WARN  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO005: Your system is configured with 1024 file descriptors, but your current application server configuration will require a minimum of 1032 (and probably more than that); attempting to adjust, however you should expect stability problems unless you increase this number
10:41:01,725 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 76) WFLYWS0002: Activating WebServices Extension
10:41:01,726 INFO  [org.wildfly.extension.microprofile.metrics.smallrye] (ServerService Thread Pool -- 64) WFLYMETRICS0001: Activating Eclipse MicroProfile Metrics Subsystem
10:41:01,696 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 74) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
10:41:01,733 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 59) WFLYJSF0007: Activated the following JSF Implementations: [main]
10:41:01,733 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 72) WFLYSEC0002: Activating Security Subsystem
10:41:01,739 INFO  [org.wildfly.extension.microprofile.opentracing] (ServerService Thread Pool -- 65) WFLYTRACEXT0001: Activating MicroProfile OpenTracing Subsystem
10:41:01,741 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO001: Worker 'default' has auto-configured to 16 IO threads with 128 max task threads based on your 8 available processors
10:41:01,740 INFO  [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=5.0.3.Final-redhat-00006
10:41:01,735 INFO  [org.jboss.as.connector] (MSC service thread 1-8) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.23.Final)
10:41:01,759 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 66) WFLYNAM0001: Activating Naming Subsystem
10:41:01,780 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0003: Undertow 2.2.2.Final starting
10:41:01,849 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 44) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
10:41:01,864 INFO  [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
10:41:01,869 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-3) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
10:41:01,881 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = h2
10:41:02,030 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 75) WFLYUT0014: Creating file handler for path '/opt/jboss/wildfly/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
10:41:02,043 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0012: Started server default-server.
10:41:02,046 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0018: Host default-host starting
10:41:02,051 INFO  [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing.
10:41:02,051 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host.
10:41:02,194 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:8080
10:41:02,297 INFO  [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0493: EJB subsystem suspension complete
10:41:02,381 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
10:41:02,549 INFO  [org.jboss.as.patching] (MSC service thread 1-2) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
10:41:02,568 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-2) WFLYDM0111: Keystore /opt/jboss/wildfly/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
10:41:02,580 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
10:41:02,668 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:8443
10:41:02,763 INFO  [org.jboss.ws.common.management] (MSC service thread 1-3) JBWS022052: Starting JBossWS 5.4.2.Final (Apache CXF 3.3.7) 
10:41:02,946 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
10:41:02,949 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) started in 3839ms - Started 317 of 579 services (370 services are lazy, passive or on-demand)
10:41:02,951 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
10:41:02,951 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990

 

SSH into Docker container
[dave@dave java-ee-8]$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
32092f4064f8        jboss/wildfly       "/opt/jboss/wildfly/…"   4 minutes ago       Up 4 minutes        8080/tcp            thirsty_mccarthy
[dave@dave java-ee-8]$ docker exec -it thirsty_mccarthy /bin/bash
[jboss@32092f4064f8 ~]$ uname -a
Linux 32092f4064f8 5.9.15-100.fc32.x86_64 #1 SMP Wed Dec 16 16:49:20 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[jboss@32092f4064f8 ~]$ more /etc/re
redhat-release  resolv.conf     
[jboss@32092f4064f8 ~]$ more /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[jboss@32092f4064f8 ~]$ ls /opt/jboss/
.bash_logout   .bash_profile  .bashrc        wildfly/       
[jboss@32092f4064f8 ~]$ ls /opt/jboss/
.bash_logout   .bash_profile  .bashrc        wildfly/       
[jboss@32092f4064f8 ~]$ ls /opt/jboss/wildfly/
.installation/     LICENSE.txt        appclient/         copyright.txt      domain/            modules/           welcome-content/   
.well-known/       README.txt         bin/               docs/              jboss-modules.jar  standalone/     

 Start the container with port mapping


[dave@dave java-ee8-minimal]$ docker run -it com.dave/java-ee8-minimal /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement=0.0.0.0
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED

=========================================================================

11:05:36,608 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.2.Final
11:05:37,223 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.12.Final
11:05:37,235 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final
11:05:37,349 WARN  [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended
11:05:37,409 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) starting

 

Create custom Docker image with added start command and admin user



$ more Dockerfile
FROM jboss/wildfly

RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent

COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]



$ docker build -t com.dave/java-ee8-minimal .
Sending build context to Docker daemon  45.06kB
Step 1/4 : FROM jboss/wildfly
latest: Pulling from jboss/wildfly
75f829a71a1c: Pull complete 
7b11f246b3d3: Pull complete 
b765648c2a58: Pull complete 
506aff4a9c5a: Pull complete 
e7e0b6e22530: Pull complete 
Digest: sha256:152a4dd6e524afa133dd200b1a4ba6411dc334dfd84921d5eafcbae85f859c00
Status: Downloaded newer image for jboss/wildfly:latest
 ---> 8d9094a2468d
Step 2/4 : RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#123 --silent
 ---> Running in aa5d352002f3
Removing intermediate container aa5d352002f3
 ---> 8b8272a09327
Step 3/4 : COPY ./target/java-ee8-minimal.war /opt/jboss/wildfly/standalone/deployments/
 ---> cc421f2ffe58
Step 4/4 : CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
 ---> Running in 1dc6700a5950
Removing intermediate container 1dc6700a5950
 ---> fc3355adcac3
Successfully built fc3355adcac3
Successfully tagged com.dave/java-ee8-minimal:latest


Get IP address

$$ docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS               NAMES
ba4374f6cbb1        com.dave/java-ee8-minimal   "/opt/jboss/wildfly/…"   4 minutes ago       Up 4 minutes        8080/tcp            java-ee8-minimal
[dave@dave java-ee-8]$ docker inspect -f '{{ .NetworkSettings.IPAddress }}' java-ee8-minimal
172.17.0.2

Start the mofified container with mapped ports and added admin user

[dave@dave java-ee8-minimal]$ docker run -it --name java-ee8-minimal com.dave/java-ee8-minimal
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED

=========================================================================

11:18:28,581 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.2.Final
11:18:29,127 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.12.Final
11:18:29,135 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final
11:18:29,219 WARN  [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended
11:18:29,286 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) starting
11:18:30,137 INFO  [org.wildfly.security] (ServerService Thread Pool -- 28) ELY00001: WildFly Elytron version 1.13.1.Final
11:18:30,739 INFO  [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
11:18:30,782 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 21) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
11:18:30,819 INFO  [org.jboss.as.repository] (ServerService Thread Pool -- 9) WFLYDR0001: Content added at location /opt/jboss/wildfly/standalone/data/content/9a/599d68cb6a082432b9ec80cfbc307a3345471e/content
11:18:30,905 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
11:18:30,921 INFO  [org.xnio] (MSC service thread 1-8) XNIO version 3.8.2.Final
11:18:30,928 INFO  [org.xnio.nio] (MSC service thread 1-8) XNIO NIO Implementation Version 3.8.2.Final
11:18:30,982 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 52) WFLYCLINF0001: Activating Infinispan subsystem.
11:18:30,969 WARN  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO005: Your system is configured with 1024 file descriptors, but your current application server configuration will require a minimum of 1032 (and probably more than that); attempting to adjust, however you should expect stability problems unless you increase this number
11:18:31,001 INFO  [org.jboss.as.jaxrs] (ServerService Thread Pool -- 54) WFLYRS0016: RESTEasy version 3.13.2.Final
11:18:31,003 INFO  [org.jboss.as.connector] (MSC service thread 1-7) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.23.Final)
11:18:31,022 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 44) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
11:18:31,038 INFO  [org.wildfly.extension.microprofile.metrics.smallrye] (ServerService Thread Pool -- 64) WFLYMETRICS0001: Activating Eclipse MicroProfile Metrics Subsystem
11:18:31,038 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = h2
11:18:31,066 INFO  [org.wildfly.extension.microprofile.jwt.smallrye._private] (ServerService Thread Pool -- 63) WFLYJWT0001: Activating WildFly MicroProfile JWT Subsystem
11:18:31,038 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 59) WFLYJSF0007: Activated the following JSF Implementations: [main]
11:18:31,069 INFO  [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 62) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
11:18:31,069 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 5.0.19.Final
11:18:31,079 INFO  [org.wildfly.extension.microprofile.opentracing] (ServerService Thread Pool -- 65) WFLYTRACEXT0001: Activating MicroProfile OpenTracing Subsystem
11:18:31,079 INFO  [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 61) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
11:18:31,083 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 53) WFLYIO001: Worker 'default' has auto-configured to 16 IO threads with 128 max task threads based on your 8 available processors
11:18:31,100 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 72) WFLYSEC0002: Activating Security Subsystem
11:18:31,105 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 66) WFLYNAM0001: Activating Naming Subsystem
11:18:31,099 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 74) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
11:18:31,103 INFO  [org.jboss.as.security] (MSC service thread 1-3) WFLYSEC0001: Current PicketBox version=5.0.3.Final-redhat-00006
11:18:31,135 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 76) WFLYWS0002: Activating WebServices Extension
11:18:31,153 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0003: Undertow 2.2.2.Final starting
11:18:31,197 INFO  [org.jboss.as.naming] (MSC service thread 1-8) WFLYNAM0003: Starting Naming Service
11:18:31,208 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-8) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
11:18:31,356 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host.
11:18:31,358 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing.
11:18:31,369 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 75) WFLYUT0014: Creating file handler for path '/opt/jboss/wildfly/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
11:18:31,382 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0012: Started server default-server.
11:18:31,400 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0018: Host default-host starting
11:18:31,507 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:8080
11:18:31,571 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0493: EJB subsystem suspension complete
11:18:31,643 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
11:18:31,878 INFO  [org.jboss.as.patching] (MSC service thread 1-3) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
11:18:31,896 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-8) WFLYDM0111: Keystore /opt/jboss/wildfly/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
11:18:31,910 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/jboss/wildfly/standalone/deployments
11:18:31,919 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "java-ee8-minimal.war" (runtime-name: "java-ee8-minimal.war")
11:18:31,989 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 0.0.0.0:8443
11:18:32,071 INFO  [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBossWS 5.4.2.Final (Apache CXF 3.3.7) 
11:18:32,618 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment java-ee8-minimal.war
11:18:32,877 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 6.0.21.Final
11:18:33,273 INFO  [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-4) No shutdown hook registered: Please call close() manually on application shutdown.
11:18:33,390 INFO  [org.jboss.weld.Version] (MSC service thread 1-3) WELD-000900: 3.1.5 (Final)
11:18:33,681 INFO  [org.infinispan.CONTAINER] (ServerService Thread Pool -- 78) ISPN000128: Infinispan version: Infinispan 'Corona Extra' 11.0.4.Final
11:18:33,743 INFO  [org.infinispan.CONFIG] (MSC service thread 1-1) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
11:18:33,745 INFO  [org.infinispan.CONFIG] (MSC service thread 1-1) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
11:18:33,870 INFO  [org.infinispan.PERSISTENCE] (ServerService Thread Pool -- 78) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.spi.marshalling.InfinispanProtoStreamMarshaller'
11:18:33,934 INFO  [io.smallrye.metrics] (MSC service thread 1-4) MicroProfile: Metrics activated (SmallRye Metrics version: 2.4.2)
11:18:34,134 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 78) WFLYCLINF0002: Started http-remoting-connector cache from ejb container
11:18:34,899 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 79) RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.airhacks.JAXRSConfiguration$Proxy$_$$_WeldClientProxy
11:18:34,959 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 79) WFLYUT0021: Registered web context: '/java-ee8-minimal' for server 'default-server'
11:18:35,066 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0010: Deployed "java-ee8-minimal.war" (runtime-name : "java-ee8-minimal.war")
11:18:35,129 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
11:18:35,133 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 21.0.1.Final (WildFly Core 13.0.3.Final) started in 7081ms - Started 441 of 664 services (375 services are lazy, passive or on-demand)
11:18:35,136 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://0.0.0.0:9990/management
11:18:35,136 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://0.0.0.0:9990


Access the Admin console at port 9990 

Access the application at http://172.17.0.2:8080/java-ee8-minimal/resources/ping

Enjoy Jakarta EE with MicroProfile 2+!

 

Create Java EE 8 mininal project from Maven archetype

 HOWTO

 

Project

 https://github.com/dveselka/java-ee-8

Generate project from Adam Bien minimal archetype

[dave@dave git]$ cd java-ee-8/
[dave@dave java-ee-8]$ mvn archetype:generate -Dfilter=com.airhacks:javaee8-essentials-archetype
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:3.1.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:3.1.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] 
[INFO] --- maven-archetype-plugin:3.1.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: remote -> com.airhacks:javaee8-essentials-archetype (Java EE 8 project quickstart template. Clean, lean and minimalistic.)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1
Choose com.airhacks:javaee8-essentials-archetype version: 
1: 0.0.1
2: 0.0.2
3: 0.0.4
Choose a number: 3: 3
Downloading from central: https://repo.maven.apache.org/maven2/com/airhacks/javaee8-essentials-archetype/0.0.4/javaee8-essentials-archetype-0.0.4.pom
Downloaded from central: https://repo.maven.apache.org/maven2/com/airhacks/javaee8-essentials-archetype/0.0.4/javaee8-essentials-archetype-0.0.4.pom (3.9 kB at 13 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/com/airhacks/javaee8-essentials-archetype/0.0.4/javaee8-essentials-archetype-0.0.4.jar
Downloaded from central: https://repo.maven.apache.org/maven2/com/airhacks/javaee8-essentials-archetype/0.0.4/javaee8-essentials-archetype-0.0.4.jar (3.9 kB at 16 kB/s)
Define value for property 'groupId': com.dave
Define value for property 'artifactId': java-ee8-minimal
Define value for property 'version' 1.0-SNAPSHOT: : 
Define value for property 'package' com.dave: : 
Confirm properties configuration:
groupId: com.dave
artifactId: java-ee8-minimal
version: 1.0-SNAPSHOT
package: com.dave
 Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: javaee8-essentials-archetype:0.0.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.dave
[INFO] Parameter: artifactId, Value: java-ee8-minimal
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.dave
[INFO] Parameter: packageInPathFormat, Value: com/dave
[INFO] Parameter: package, Value: com.dave
[INFO] Parameter: groupId, Value: com.dave
[INFO] Parameter: artifactId, Value: java-ee8-minimal
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Project created from Archetype in dir: /git/java-ee-8/java-ee8-minimal
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  52.463 s
[INFO] Finished at: 2020-12-27T10:48:01+01:00
[INFO] ------------------------------------------------------------------------

 

Generated project
[dave@dave java-ee-8]$ find java-ee8-minimal/
java-ee8-minimal/
java-ee8-minimal/pom.xml
java-ee8-minimal/Dockerfile
java-ee8-minimal/README.md
java-ee8-minimal/buildAndRun.sh
java-ee8-minimal/src
java-ee8-minimal/src/main
java-ee8-minimal/src/main/java
java-ee8-minimal/src/main/java/com
java-ee8-minimal/src/main/java/com/airhacks
java-ee8-minimal/src/main/java/com/airhacks/JAXRSConfiguration.java
java-ee8-minimal/src/main/java/com/airhacks/ping
java-ee8-minimal/src/main/java/com/airhacks/ping/boundary
java-ee8-minimal/src/main/java/com/airhacks/ping/boundary/PingResource.java
java-ee8-minimal/src/main/resources
java-ee8-minimal/src/main/resources/META-INF
java-ee8-minimal/src/main/resources/META-INF/microprofile-config.properties
java-ee8-minimal/src/main/webapp
java-ee8-minimal/src/main/webapp/WEB-INF
java-ee8-minimal/src/main/webapp/WEB-INF/beans.xml

 

Monday, November 30, 2020

Configure Jenkins agent using declarative pipeline

HOWTO

Sample projects

 

Configure Jenkins agent

agent

    The agent section specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent section is placed. The section must be defined at the top-level inside the pipeline block, but stage-level usage is optional.

 

label 
  
   Execute the Pipeline, or stage, on an agent available in the Jenkins environment with the provided label. For example: agent { label 'my-defined-label' }

 

node

agent { node { label 'labelName' } } behaves the same as agent { label 'labelName' }, but node allows for additional options (such as customWorkspace).

 

Multiple agents

pipeline {
    agent none
    stages {
        stage('Build') {
            agent any
            steps {
                checkout scm
                sh 'make'
                stash includes: '**/target/*.jar', name: 'app' 
            }
        }
        stage('Test on Linux') {
            agent { 
                label 'linux'
            }
            steps {
                unstash 'app' 
                sh 'make check'
            }
            post {
                always {
                    junit '**/target/*.xml'
                }
            }
        }
        stage('Test on Windows') {
            agent {
                label 'windows'
            }
            steps {
                unstash 'app'
                bat 'make check' 
            }
            post {
                always {
                    junit '**/target/*.xml'
                }
            }
        }
    }
} 
Configure GitHub credentials for Jenkins

Configure pipeline 

GitHub credentials must be username/password ( use GH token) 

https://stackoverflow.com/questions/38461705/checkout-jenkins-pipeline-git-scm-with-credentials?rq=1

If you're using the ssh url then your credentials must be username + private key. If you're using the https clone url instead of the ssh one, then your credentials should be username + password.

 To change working dir use dir ('somedir'){ ... }

https://github.com/dveselka/weblogic/blob/master/Jenkinsfile  

node {

        stage('Checkout') {
          git url: 'https://github.com/dveselka/weblogic/', credentialsId: 'dave-devops', branch: 'weblogic-14.1.1'
        }

        stage('Build') {
            dir ('dave-basic-webapp-ejb-project') {
                withMaven(maven:'local') {
                   sh 'mvn clean package'

                   def pom = readMavenPom file:'pom.xml'
                   print pom.version
                   env.version = pom.version
                }
            }     
        }

}

Install Maven pipeline plugin

https://www.jenkins.io/doc/pipeline/steps/pipeline-maven/

https://plugins.jenkins.io/pipeline-maven/

Install  Pipeline utility steps plugin

https://plugins.jenkins.io/pipeline-utility-steps/

 

Configure Maven 

dave@dave ~]$ which mvn
/opt/maven/bin/mvn
[dave@dave ~]$ mvn --version
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: /opt/maven
Java version: 11.0.9, vendor: Oracle Corporation, runtime: /usr/java/jdk-11.0.9
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.9.15-100.fc32.x86_64", arch: "amd64", family: "unix"

https://docs.oracle.com/en/middleware/fusion-middleware/weblogic-server/12.2.1.4/wlprg/maven.html#GUID-C6FC7582-2D1C-4EA5-B000-71AE9A2F2B05


 Configure Oracle Maven repository for Weblogic


[dave@dave 14.1.1]$ cd /app/weblogic/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/14.1.1/^C
[dave@dave 14.1.1]$ mvn install:install-file -DpomFile=oracle-maven-sync-14.1.1.pom -Dfile=oracle-maven-sync-14.1.1.jar
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /app/weblogic/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/14.1.1/oracle-maven-sync-14.1.1.jar to /home/dave/.m2/repository/com/oracle/maven/oracle-maven-sync/14.1.1-0-0/oracle-maven-sync-14.1.1-0-0.jar
[INFO] Installing /app/weblogic/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/14.1.1/oracle-maven-sync-14.1.1.pom to /home/dave/.m2/repository/com/oracle/maven/oracle-maven-sync/14.1.1-0-0/oracle-maven-sync-14.1.1-0-0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

Install Oracle artifacts into local repo
[dave@dave 14.1.1]$ mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/app/weblogic

 

Build pipeline 

 

Started by user DaVe
Obtained Jenkinsfile from git https://github.com/dveselka/weblogic/
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/weblogic-pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout)
[Pipeline] git
The recommended git tool is: NONE
using credential dave-devops
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/dveselka/weblogic/ # timeout=10
Fetching upstream changes from https://github.com/dveselka/weblogic/
 > git --version # timeout=10
 > git --version # 'git version 2.26.2'
using GIT_ASKPASS to set credentials dave-devops
 > git fetch --tags --force --progress -- https://github.com/dveselka/weblogic/ +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/weblogic-14.1.1^{commit} # timeout=10
Checking out Revision d880e4d74b8302545401074d68fd449115fdca1b (refs/remotes/origin/weblogic-14.1.1)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f d880e4d74b8302545401074d68fd449115fdca1b # timeout=10
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D weblogic-14.1.1 # timeout=10
 > git checkout -b weblogic-14.1.1 d880e4d74b8302545401074d68fd449115fdca1b # timeout=10
Commit message: "Merge pull request #2 from dveselka/master"
 > git rev-list --no-walk 7fe92410b7aab93803b8dbd39200a48c23331709 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project
[Pipeline] {
[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options: 
[withMaven] using JDK installation provided by the build agent
[withMaven] using Maven installation 'local'
[Pipeline] {
[Pipeline] sh
+ mvn clean package
----- withMaven Wrapper script -----
Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project@tmp/withMaven8d13bb8c/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project@tmp/withMaven8d13bb8c" 
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: /opt/maven
Java version: 11.0.9, vendor: Oracle Corporation, runtime: /usr/java/jdk-11.0.9
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.9.15-100.fc32.x86_64", arch: "amd64", family: "unix"
[INFO] [jenkins-event-spy] Generate /var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project@tmp/withMaven8d13bb8c/maven-spy-20201227-095826-57316330863830296583212.log.tmp ...
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------< dave:dave-basic-webapp-ejb-project >-----------------
[INFO] Building basicWebappEjb 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ dave-basic-webapp-ejb-project ---
[INFO] Deleting /var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ dave-basic-webapp-ejb-project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ dave-basic-webapp-ejb-project ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 6 source files to /var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ dave-basic-webapp-ejb-project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ dave-basic-webapp-ejb-project ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ dave-basic-webapp-ejb-project ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ dave-basic-webapp-ejb-project ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/var/lib/jenkins/.m2/repository/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar) to field java.util.Properties.defaults
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Packaging webapp
[INFO] Assembling webapp [dave-basic-webapp-ejb-project] in [/var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project/target/basicWebappEjb]
[INFO] Processing war project
[INFO] Copying webapp resources [/var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project/src/main/webapp]

[INFO] Webapp assembled in [33 msecs]
[INFO] Building war: /var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project/target/basicWebappEjb.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.763 s
[INFO] Finished at: 2020-12-27T09:58:29+01:00
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/weblogic-pipeline/dave-basic-webapp-ejb-project@tmp/withMaven8d13bb8c/maven-spy-20201227-095826-57316330863830296583212.log
[Pipeline] readMavenPom
[Pipeline] echo
1.0-SNAPSHOT
[Pipeline] }
[withMaven] artifactsPublisher - Archive artifact pom.xml under dave/dave-basic-webapp-ejb-project/1.0-SNAPSHOT/dave-basic-webapp-ejb-project-1.0-SNAPSHOT.pom
[withMaven] artifactsPublisher - Archive artifact target/basicWebappEjb.war under dave/dave-basic-webapp-ejb-project/1.0-SNAPSHOT/dave-basic-webapp-ejb-project-1.0-SNAPSHOT.war
[withMaven] junitPublisher - Archive test results for Maven artifact dave:dave-basic-webapp-ejb-project:war:1.0-SNAPSHOT generated by maven-surefire-plugin:test (default-test): target/surefire-reports/*.xml
[withMaven] junitPublisher - Jenkins JUnit Attachments Plugin not found, can't publish test attachments.Recording test results
None of the test reports contained any result
[withMaven] Jenkins Task Scanner Plugin not found, don't display results of source code scanning for 'TODO' and 'FIXME' in pipeline screen.
[withMaven] Publishers: Pipeline Graph Publisher: 3 ms, Generated Artifacts Publisher: 17 ms, Junit Publisher: 31 ms
[Pipeline] // withMaven
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

 

Saturday, November 28, 2020

Install Jenkins via Ansible

HOWTO 


  • Install Jenkins using Galaxy role  https://training.galaxyproject.org/training-material/topics/admin/tutorials/jenkins/tutorial.html



Clone repository with playbook

https://github.com/dveselka/devops-ansible/tree/master/jenkins

[dave@dave ~]$ git clone https://github.com/dveselka/devops-ansible

Install Ansible Galaxy roles
[dave@dave ~]$ cd devops-ansible/
[dave@dave devops-ansible]$ cd jenkins/
[dave@dave jenkins]$ ls
create_jenkins.yml  dev_vars.yml  README.md  requirements.yml
[dave@dave jenkins]$ ansible-galaxy install -p roles -r requirements.yml
- downloading role 'java', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-java/archive/1.10.0.tar.gz
- extracting geerlingguy.java to /home/dave/devops-ansible/jenkins/roles/geerlingguy.java
- geerlingguy.java (1.10.0) was installed successfully
- downloading role 'jenkins', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-jenkins/archive/4.3.0.tar.gz
- extracting geerlingguy.jenkins to /home/dave/devops-ansible/jenkins/roles/geerlingguy.jenkins
- geerlingguy.jenkins (4.3.0) was installed successfully


Check Java version
[dave@dave jenkins]$ java -version
java version "11.0.9" 2020-10-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)



Run Ansible playbook
[dave@dave jenkins]$ ansible-playbook -K  create_jenkins.yml 
BECOME password: 
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [Install Jenkins on localhost] *****************************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.java : Include OS-specific variables for Fedora or FreeBSD.] **********************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.java : Include version-specific variables for CentOS/RHEL.] ***********************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.java : Include version-specific variables for Ubuntu.] ****************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.java : Include version-specific variables for Debian.] ****************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.java : Define java_packages.] *****************************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.java : include_tasks] *************************************************************************************************************************************************************************
included: /home/dave/devops-ansible/jenkins/roles/geerlingguy.java/tasks/setup-RedHat.yml for localhost

TASK [geerlingguy.java : Ensure Java is installed.] *************************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.java : include_tasks] *************************************************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.java : include_tasks] *************************************************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.java : Set JAVA_HOME if configured.] **********************************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Include OS-Specific variables] ******************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Define jenkins_repo_url] ************************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Define jenkins_repo_key_url] ********************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Define jenkins_pkg_url] *************************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : include_tasks] **********************************************************************************************************************************************************************
included: /home/dave/devops-ansible/jenkins/roles/geerlingguy.jenkins/tasks/setup-RedHat.yml for localhost

TASK [geerlingguy.jenkins : Ensure dependencies are installed.] *************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Ensure Jenkins repo is installed.] **************************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Add Jenkins repo GPG key.] **********************************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Download specific Jenkins version.] *************************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.jenkins : Check if we downloaded a specific version of Jenkins.] ******************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.jenkins : Install our specific version of Jenkins.] *******************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.jenkins : Ensure Jenkins is installed.] *******************************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : include_tasks] **********************************************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.jenkins : include_tasks] **********************************************************************************************************************************************************************
included: /home/dave/devops-ansible/jenkins/roles/geerlingguy.jenkins/tasks/settings.yml for localhost

TASK [geerlingguy.jenkins : Check if jenkins_init_file exists.] *************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Ensure jenkins_init_file exists.] ***************************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.jenkins : Modify variables in init file.] *****************************************************************************************************************************************************
changed: [localhost] => (item={'option': 'JENKINS_ARGS', 'value': '--prefix='})
changed: [localhost] => (item={'option': 'JENKINS_JAVA_OPTIONS', 'value': '-Xmx4096M'})

TASK [geerlingguy.jenkins : Ensure jenkins_home /var/lib/jenkins exists.] ***************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Set the Jenkins home directory.] ****************************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Immediately restart Jenkins on init config changes.] ********************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Set HTTP port in Jenkins config.] ***************************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Create custom init scripts directory.] **********************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Configure proxy config for Jenkins] *************************************************************************************************************************************************
skipping: [localhost]

RUNNING HANDLER [geerlingguy.jenkins : configure default users] *************************************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Immediately restart Jenkins on http or user changes.] *******************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Ensure Jenkins is started and runs on startup.] *************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Wait for Jenkins to start up before proceeding.] ************************************************************************************************************************************
FAILED - RETRYING: Wait for Jenkins to start up before proceeding. (60 retries left).
FAILED - RETRYING: Wait for Jenkins to start up before proceeding. (59 retries left).
FAILED - RETRYING: Wait for Jenkins to start up before proceeding. (58 retries left).
ok: [localhost]

TASK [geerlingguy.jenkins : Get the jenkins-cli jarfile from the Jenkins server.] *******************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : Remove Jenkins security init scripts after first startup.] **************************************************************************************************************************
changed: [localhost]

TASK [geerlingguy.jenkins : include_tasks] **********************************************************************************************************************************************************************
included: /home/dave/devops-ansible/jenkins/roles/geerlingguy.jenkins/tasks/plugins.yml for localhost

TASK [geerlingguy.jenkins : Get Jenkins admin password from file.] **********************************************************************************************************************************************
skipping: [localhost]

TASK [geerlingguy.jenkins : Set Jenkins admin password fact.] ***************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Create Jenkins updates directory.] **************************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Download current plugin updates from Jenkins update site.] **************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Remove first and last line from json file.] *****************************************************************************************************************************************
ok: [localhost]

TASK [geerlingguy.jenkins : Install Jenkins plugins using password.] ********************************************************************************************************************************************

PLAY RECAP ******************************************************************************************************************************************************************************************************
localhost                  : ok=34   changed=13   unreachable=0    failed=0    skipped=13   rescued=0    ignored=0   


Configure nodes 

https://www.howtoforge.com/tutorial/ubuntu-jenkins-master-slave/



Tuesday, November 10, 2020

Google Cloud code IDE extension

HOWTO

 

Install VS Code https://code.visualstudio.com/docs/setup/linux#_installation

rpm --import https://packages.microsoft.com/keys/microsoft.asc
sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
dnf check-update
dnf install code

Install Google Code extension into VS Code

To use custom versions of Cloud Code dependencies:

  1. Click settings Manage > Settings and then set Auto Dependencies (cloudcode.autoDependencies) to off.

  2. Install the following dependencies on your PATH:


Open k8s project 

 https://github.com/dveselka/devops-k8s/tree/main/complex

Terraform project 


 

Azure Terraform - add extension 

 https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureterraform

 



Bridge to minikube 

https://code.visualstudio.com/docs/containers/bridge-to-kubernetes

 



Weblogic - Docker compose 

https://github.com/oracle/docker-images/tree/master/OracleWebLogic

 


 

Deploy application on Google Cloud k8s using Travis

 HOWTO

See other blogs entries

 

GitHub repos

 

Deployed application - Google Cloud console

 





Travis CI





 

 

 

Install Ingress using Helm on Google cloud

 HOWTO

 https://helm.sh/docs/intro/install/#from-script

 https://helm.sh/docs/intro/using_helm/

 https://github.com/kubernetes/ingress-nginx

https://kubernetes.github.io/ingress-nginx/deploy/#using-helm


Install Helm

daniel_veselka@cloudshell:~ (genial-acronym-295114)$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
daniel_veselka@cloudshell:~ (genial-acronym-295114)$ chmod 700 get_helm.sh
daniel_veselka@cloudshell:~ (genial-acronym-295114)$ ./get_helm.sh
Helm v3.4.0 is available. Changing from version v3.2.1.
Downloading https://get.helm.sh/helm-v3.4.0-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm
daniel_veselka@cloudshell:~ (genial-acronym-295114)$ helm version
version.BuildInfo{Version:"v3.4.0", GitCommit:"7090a89efc8a18f3d8178bf47d2462450349a004", GitTreeState:"clean", GoVersion:"go1.14.10"}

Install Ingress

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install my-release ingress-nginx/ingress-nginx

daniel_veselka@cloudshell:~ (genial-acronym-295114)$ POD_NAME=$(kubectl get pods -l app.kubernetes.io/name=ingress-nginx -o jsonpath='{.items[0].metadata.name}')
daniel_veselka@cloudshell:~ (genial-acronym-295114)$ kubectl exec -it $POD_NAME -- /nginx-ingress-controller --version
-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:       v0.41.0
  Build:         f3a6b809bd4bb6608266b35cf5b8423bf107d7bc
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.19.4

-------------------------------------------------------------------------------

Configure user access - service accounts and roles

k8s namespaces on GCP

daniel_veselka@cloudshell:~ (genial-acronym-295114)$ kubectl get namespaces
NAME              STATUS   AGE
default           Active   15h
kube-node-lease   Active   15h
kube-public       Active   15h
kube-system       Active   15h

Configure roles - not required with Helm3 - tiller removed

daniel_veselka@cloudshell:~ (genial-acronym-295114)$ kubectl create serviceaccount --namespace kube-system tiller
serviceaccount/tiller created
daniel_veselka@cloudshell:~ (genial-acronym-295114)$ kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-systen:tiller
clusterrolebinding.rbac.authorization.k8s.io/tiller-cluster-rule created


HTTPS configuration

  • https://github.com/StephenGrider/multi-k8s/blob/master/k8s/certificate.yaml
  • https://github.com/StephenGrider/multi-k8s/blob/master/k8s/issuer.yaml