Sonarqube running in Podman containers

This is a quick entry to show how to run sonarqube using Podman. Please note that I’m using windows powershell.

First, create the next directory structure and add the following SQL script into sql directory:

\SONARQUBE
\---sql
    init-dabase.sql

Script content:

-- Creating db user and database for sonarqube

CREATE USER mysonaruser PASSWORD 'mypassword';
CREATE DATABASE sonarqube OWNER mysonaruser;

Open that directory into the terminal, download the images from docker repository and create the volumes.

# Download images

podman pull postgres:15.4
podman pull sonarqube:9.9.2-community

# Create volumes

podman volume create sonarqube_data
podman volume create sonarqube_logs
podman volume create sonarqube_extensions
podman volume create postgres-data

There are two ways to run the containers, creating a network or run in the same pod, please choose only one of the next.

Seguir leyendo

Tips on Install Jenkins on Mac OSX

logo-title

Jenkins is the most popular application server to automate tasks related with the software development life cycle, this tool can execute and manage tasks to build, test and deliver software in a perspective like a continious process of software manufacture.

To install in macOS is a very simple process (even in windows or linux), I don’t going to explain it because the installer have a very clear assistance, if you need some help,, you can follow the steps of this guide (with screenshots), instead I want to write about the some simple tips after the installation. Seguir leyendo

Create ssh tunnel with Putty

This is a simple trick to use a unix server as bridge to achieve other host or services like as local service, for example, I’ve a instance of jboss running in a server but I’cant access to the server directly, if I open the url: http://remotehost:8080 the error is not found page in browser.

Then go to putty configuration ( Connection > SSH > Tunnels) and add a simple tunnel:

  • Source port: the port to access the server from your localhost
  • Destination: the hostname:port of the remote service

2019-06-17 17_10_48-PuTTY Configuration Seguir leyendo

Jenkins execute script over ssh

logo-title

To execute a shell script with jenkins into a remote server it’s very easy task, you can use a sshPublisher plugin or configure manually, in this entry I’m going to show how to do it using ssh key pair.

To avoid login prompt in command line, setup a ssh keys in your jenkins instance and copy the public key to the remote server.

Setup the autentication

1. Create a ssh key pair in your jenkins server, login into the jenkins server with the user that is currently running the application server and execute the ssh-keygen command:

sudo su -s /bin/bash jenkins
ssh-keygen -t rsa

Leave the options by default to create a file ~/.ssh/id_rsa, but take care if you have a previous one, this will be overwriten. Or you can set another name for the key pair, I’m going to use id_dummy without passhrase.

Output:

bash-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/jenkins/.ssh/id_rsa): /var/lib/jenkins/.ssh/id_dummy
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/jenkins/.ssh/id_dummy.
Your public key has been saved in /var/lib/jenkins/.ssh/id_dummy.pub.

Note: The passhrase is an aditional method to keep the keys safe in case that your lost it.

2. Copy the public key to remote server using the command ssh-copy-id

ssh-copy-id -i ~/.ssh/id_dummy username@remote_host

If the command it’s not available you can do it manually with this:

cat ~/.ssh/id_dummy.pub | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"
Seguir leyendo

Install Oracle Driver Jboss Wildfly 14

Create new module with this structure and files, into «$WILDFLY_HOME\modules\system\layers\base«:

+---com
|   \---oracle
|       \---main
|            module.xml
|            ojdbc7-12.1.0.2.jar

Into the module.xml, set a name of the module and put it into the same folder structure «com.oracle» with the jar file.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
    <resources>
        <resource-root path="ojdbc7-12.1.0.2.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>
Seguir leyendo

Setup CI Server in Cloud for Java projects with code coverage and inspection

logos CI

Yep!  I was wating a long time to wirte about this topic, but finally I’m going to show  how to setup your own Continous Integration Server (aka CI) using cloud services, all of them with free accounts.

Only consider the scope of the functionality is very limited because all services we’re using are free, but if pay for it you can do much more.

I don’t going to explain what is or what are the feautres of the CI server, only I want to say the CI is a concept created by Martin Fowler in 2006 and like he’s mention in her website:

«Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily – leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly.»

Well, let’s get started. We’re going to configure and integrate the next services, so you only need your Github or Bitbucket account.

The demo project

Seguir leyendo

Install Java JDK on Server (Suse)

La instalación del a jdk en servidores Unix puede generar a veces algunos problemas ya que generalmente no hay una guía exacta para realizar la instalación, pero desde mi punto de vista creo que también se debe a que en internet hay muchas formas de hacerlo y también es verdad que Unix lo permite, por lo tanto no hay una forma «correcta» de hacerlo.

Sin embargo hay una forma de mantener un orden dentro de todo este caos, por ejemplo hay servidores que a veces necesitan tener instaladas dos o más versiones de la jdk en el mismo server… y ¿como controlamos esto? este tipo de cuestiones son las que causan esos problemas  a los que me refiero porque muchos ajustamos variables de entorno y terminamos creando un dessatre, y bueno antes de mostrar la instalación quería transmitir esta pequeña perspectiva.

El siguiente comando es el que nos a ayudar en Suse a controlar esto:

update-alternatives

Nota: en Ubuntu el equivalente es el comando alternatives
Seguir leyendo

Suse add Jboss 5 Startup Script

Este es uno de esos días que me arrepiento por no guardar esos buenos tips que voy descubriendo, sé que en algún momento me pueden servir y hoy es uno de esos días ¬_¬…

Para agregar un script para ejecutar el jboss al iniciar el sistema en SUSE tenemos que seguir unos sencillos pasos:

  1. Crear archivo, generas un archivo de texto llamado jboss en la carpeta /etc/init.d con el siguiente contenido:
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: JBOSS
    # Required-Start:
    # Required-Stop:
    # Default-Start: 5
    # Default-Stop:
    # Description: Start Jboss Aplication Server 5.1 to allow and provide QA Environment the "Publicador Promociones"
    ### END INIT INFO
    export JBOSS_HOME=/opt/jboss-5.1.0.GA
    start(){
    echo "Starting jboss..."
    # If using an SELinux system such as RHEL 4, use the command below
    # instead of the "su":
    # eval "runuser - jboss -c '/opt/jboss/current/bin/run.sh > /dev/null 2> /dev/null &'
    # if the 'su -l ...' command fails (the -l flag is not recognized by my su cmd) try:
    $JBOSS_HOME/bin/run.sh -Djboss.as.deployment.ondemand=false -b 0.0.0.0 > /dev/null 2> /dev/null &
    #Su -l jboss -c '$JBOSS_HOME/bin/run.sh > /dev/null 2> /dev/null &'
    }
    stop(){
    echo "Stopping jboss..."
    # If using an SELinux system such as RHEL 4, use the command below
    # instead of the "su":
    # eval "runuser - jboss -c '/opt/jboss/current/bin/shutdown.sh -S &'
    # if the 'su -l ...' command fails try:
    $JBOSS_HOME/bin/shutdown.sh -S &
    #su -l jboss -c '$JBOSS_HOME/bin/shutdown.sh -S &'
    }
    restart(){
    stop
    # give stuff some time to stop before we restart
    sleep 60
    # protect against any services that can't stop before we restart (warning this kills all Java instances running as 'jboss' user)
    #su -l jboss -c 'killall java'
    # if the 'su -l ...' command fails try:
    # sudo -u jboss killall java
    start
    }
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    restart
    ;;
    *)
    echo "Usage: jboss {start|stop|restart}"
    exit 1
    esac
    exit 0
    view raw jboss hosted with ❤ by GitHub
  2. Le otorgas permisos de ejecución:
    chmod +x jboss
  3. Agregas el script al sistema:
    insserv /etc/init.d/jboss
    ln -s /etc/init.d/jboss /sbin/rcjboss

Para configurar el inicio y el fin debes editar el contenido del script en la sección BEGIN INIT INFO.

Referencias

Saludos

Apache, Instalar Certificado de Seguridad Privado

Para continuar con la parte de certificados de seguridad SSL vamos a crear uno privado utilizarlo internamente. En el artículo anterior deje un pequeño resumen sobre SSL, pero aqúi voy a dejar la misma introducción.

Si un día te piden un portal o servicio seguro y validado por https necesitas algo llamado SSL (Secure Socket Layer) que básicamente es un protocolo para transferir datos de forma segura, y se utiliza para:

Compartir información mediante un mecanismo de codificación entre el cliente y el servidor (aquí pueden leer un resumen bastante claro)

Esto se hace por medio de un certificado de seguridad.

El certificado es un comprobante que emite un CA (Certificate Authority) o un tercero para garantizar que el sitio web pertenece a la empresa u organización, que es un sitio legitimo, válido y seguro. En esta ocasión vamos a emitir un certificado propío o privado para cuestiones internas.

Es muy común ver esto en páginas de intranet o en redes privadas donde se necesita transferir información sensible y confidencial, por ejemplo con transacciones de negocio, datos confidenciales, cuentas, etc… también se utilizan en procesos entre servers, como en web services.

Instalación

Los pasos que voy a describir funcionan en linux, pero si lo necesitas para windows y Mac es prácticamente lo mismo solo cambian las rutas de los archivos de configuración y la instalación del software. Seguir leyendo