tachtler:gitlab_centos_7_-_ci_cd
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende ÜberarbeitungLetzte ÜberarbeitungBeide Seiten der Revision | ||
tachtler:gitlab_centos_7_-_ci_cd [2018/12/08 07:19] – [Directory Listing: Builds: FooterMilter] klaus | tachtler:gitlab_centos_7_-_ci_cd [2018/12/08 07:47] – [jar_build_footermilter.sh - Pipeline Ausgabe] klaus | ||
---|---|---|---|
Zeile 45: | Zeile 45: | ||
auskommt. | auskommt. | ||
- | ==== .gitlab-ci.yml | + | ==== .gitlab-ci.yml |
Nachfolgende Konfigurationsdatei für die [[https:// | Nachfolgende Konfigurationsdatei für die [[https:// | ||
Zeile 1331: | Zeile 1331: | ||
Eine Ausgabe in etwa wie nachfolgende sollte erscheinen, wenn der **" | Eine Ausgabe in etwa wie nachfolgende sollte erscheinen, wenn der **" | ||
- | FIXME - Projekt - CI /CD - Jobs - job_jar_build_footermilter | + | {{: |
==== jar_test_footermilter.sh ==== | ==== jar_test_footermilter.sh ==== | ||
Zeile 1367: | Zeile 1367: | ||
<code bash> | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | ############################################################################## | ||
+ | # Script-Name : jar_test_footermilter.sh | ||
+ | # Description : Script to test a web application java classes with. # | ||
+ | # # | ||
+ | # # | ||
+ | # # | ||
+ | # # | ||
+ | # Last update : 07.12.2018 | ||
+ | # Version | ||
+ | # # | ||
+ | # Author | ||
+ | # DokuWiki | ||
+ | # Homepage | ||
+ | # # | ||
+ | # +----------------------------------------------------------------------+ | ||
+ | # | This program is free software; you can redistribute it and/or modify | # | ||
+ | # | it under the terms of the GNU General Public License as published by | # | ||
+ | # | the Free Software Foundation; either version 2 of the License, or | # | ||
+ | # | (at your option) any later version. | ||
+ | # +----------------------------------------------------------------------+ | ||
+ | # # | ||
+ | # Copyright (c) 2018 by Klaus Tachtler. | ||
+ | # # | ||
+ | ############################################################################## | ||
+ | |||
+ | ############################################################################## | ||
+ | # H I S T O R Y # | ||
+ | ############################################################################## | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | # Version | ||
+ | # Description : < | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | # Version | ||
+ | # Description : < | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | # Version | ||
+ | # Description : < | ||
+ | # -------------------------------------------------------------------------- # | ||
+ | ############################################################################# | ||
+ | |||
+ | ############################################################################## | ||
+ | # >>> | ||
+ | ############################################################################## | ||
+ | |||
+ | # CUSTOM - Script-Name. | ||
+ | SCRIPT_NAME=' | ||
+ | |||
+ | # CUSTOM - Build-Environment settings. | ||
+ | CUSTOM_DIR=${CI_PROJECT_DIR} | ||
+ | JARAPP_DIR='/ | ||
+ | TARGET_DIR='/ | ||
+ | TARGET_JAR=' | ||
+ | |||
+ | # CUSTOM - Mail-Recipient. | ||
+ | MAIL_RECIPIENT=' | ||
+ | |||
+ | # CUSTOM - Status-Mail [Y|N]. | ||
+ | MAIL_STATUS=' | ||
+ | |||
+ | ############################################################################## | ||
+ | # >>> | ||
+ | ############################################################################## | ||
+ | |||
+ | # Variables. | ||
+ | JAVAC_COMMAND=`command -v javac` | ||
+ | JAVA_COMMAND=`command -v java` | ||
+ | FIND_COMMAND=`command -v find` | ||
+ | TOUCH_COMMAND=`command -v touch` | ||
+ | CP_COMMAND=`command -v cp` | ||
+ | RM_COMMAND=`command -v rm` | ||
+ | CAT_COMMAND=`command -v cat` | ||
+ | DATE_COMMAND=`command -v date` | ||
+ | MKDIR_COMMAND=`command -v mkdir` | ||
+ | PROG_SENDMAIL=`command -v sendmail` | ||
+ | FILE_LOCK='/ | ||
+ | FILE_LOG=$TARGET_DIR$SCRIPT_NAME' | ||
+ | FILE_LAST_LOG='/ | ||
+ | FILE_MAIL='/ | ||
+ | VAR_HOSTNAME=`uname -n` | ||
+ | VAR_SENDER=' | ||
+ | VAR_EMAILDATE=`$DATE_COMMAND '+%a, %d %b %Y %H:%M:%S (%Z)'` | ||
+ | |||
+ | # Functions. | ||
+ | function log() { | ||
+ | echo $1 | ||
+ | echo `$DATE_COMMAND ' | ||
+ | } | ||
+ | |||
+ | function retval() { | ||
+ | if [ " | ||
+ | case " | ||
+ | *) | ||
+ | log " | ||
+ | ;; | ||
+ | esac | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | function movelog() { | ||
+ | $CAT_COMMAND $FILE_LAST_LOG >> $FILE_LOG | ||
+ | $RM_COMMAND -f $FILE_LAST_LOG | ||
+ | $RM_COMMAND -f $FILE_LOCK | ||
+ | } | ||
+ | |||
+ | function sendmail() { | ||
+ | case " | ||
+ | ' | ||
+ | MAIL_SUBJECT=' | ||
+ | ;; | ||
+ | *) | ||
+ | MAIL_SUBJECT=' | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | $CAT_COMMAND << | ||
+ | Subject: $MAIL_SUBJECT | ||
+ | Date: $VAR_EMAILDATE | ||
+ | From: $VAR_SENDER | ||
+ | To: $MAIL_RECIPIENT | ||
+ | |||
+ | |||
+ | $CAT_COMMAND $FILE_LAST_LOG >> $FILE_MAIL | ||
+ | |||
+ | $PROG_SENDMAIL -f $VAR_SENDER -t $MAIL_RECIPIENT < $FILE_MAIL | ||
+ | |||
+ | $RM_COMMAND -f $FILE_MAIL | ||
+ | |||
+ | } | ||
+ | |||
+ | # Main. | ||
+ | log "" | ||
+ | log " | ||
+ | log "| Start test script to run junit web tests on commandline by hand.|" | ||
+ | log " | ||
+ | log "" | ||
+ | log "Run script with following parameter:" | ||
+ | log "" | ||
+ | log " | ||
+ | log " | ||
+ | log " | ||
+ | log " | ||
+ | log "" | ||
+ | log " | ||
+ | log " | ||
+ | log "" | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 11 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 12 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 13 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 14 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 15 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 16 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 17 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 18 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 19 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if command (file) NOT exist OR IS empty. | ||
+ | if [ ! -s " | ||
+ | log "Check if command ' | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 20 | ||
+ | else | ||
+ | log "Check if command ' | ||
+ | fi | ||
+ | |||
+ | # Check if LOCK file NOT exist. | ||
+ | if [ ! -e " | ||
+ | log "Check if script is NOT already runnig .........................[ | ||
+ | |||
+ | $TOUCH_COMMAND $FILE_LOCK | ||
+ | else | ||
+ | log "Check if script is NOT already runnig .........................[FAILED]" | ||
+ | log "" | ||
+ | log " | ||
+ | log "" | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 20 | ||
+ | fi | ||
+ | |||
+ | # Start build process | ||
+ | log "" | ||
+ | log " | ||
+ | log "| Run tests process ............................................. |" | ||
+ | log " | ||
+ | log "" | ||
+ | |||
+ | # Step 01: Make target directory. | ||
+ | # Check if TARGET_DIR exists. If yes delete it ande make it again. If no make it. | ||
+ | if [ ! -d " | ||
+ | log "Check if TARGET_DIR exists.................................[FAILED]" | ||
+ | $MKDIR_COMMAND -p $TARGET_DIR | ||
+ | log " | ||
+ | else | ||
+ | log "Check if TARGET_DIR exists.................................[ | ||
+ | $RM_COMMAND -rf $TARGET_DIR | ||
+ | log " | ||
+ | $MKDIR_COMMAND -p $TARGET_DIR | ||
+ | log " | ||
+ | fi | ||
+ | |||
+ | # Step 02: Change into target directory. | ||
+ | log " | ||
+ | cd $TARGET_DIR | ||
+ | |||
+ | # Step 03: Copy jarapp directorys and files to target directory. | ||
+ | log "Copy JARAPP_DIR to TARGET_DIR .............................[ | ||
+ | $CP_COMMAND -ar $JARAPP_DIR/ | ||
+ | # Step 04: Test the TARGET_JAR. | ||
+ | log "Test the TARGET_JAR .......................................[ | ||
+ | $JAVA_COMMAND -jar $TARGET_JAR -h > jartest.result | ||
+ | |||
+ | # Delete LOCK file. | ||
+ | if [ " | ||
+ | retval $? | ||
+ | log "" | ||
+ | $RM_COMMAND -f $FILE_LOCK | ||
+ | sendmail ERROR | ||
+ | movelog | ||
+ | exit 99 | ||
+ | else | ||
+ | log "" | ||
+ | log " | ||
+ | log "| End tests process ............................................. |" | ||
+ | log " | ||
+ | log "" | ||
+ | fi | ||
+ | |||
+ | # Finish syncing. | ||
+ | log " | ||
+ | log "| Finish......................................................... |" | ||
+ | log " | ||
+ | log "" | ||
+ | |||
+ | # Status e-mail. | ||
+ | if [ $MAIL_STATUS = ' | ||
+ | sendmail STATUS | ||
+ | fi | ||
+ | |||
+ | # Check the result of Failures. | ||
+ | $CAT_COMMAND $TARGET_DIR/ | ||
+ | if grep -Fxqi Exception $TARGET_DIR/ | ||
+ | then | ||
+ | log "Check the result of failures ..............................[FOUND!]" | ||
+ | log "" | ||
+ | # Move temporary log to permanent log | ||
+ | movelog | ||
+ | exit 66 | ||
+ | else | ||
+ | log "Check the result of failures ..............................[ | ||
+ | log "" | ||
+ | movelog | ||
+ | fi | ||
+ | |||
+ | exit 0 | ||
</ | </ | ||
Zeile 1440: | Zeile 1778: | ||
sollte nun in etwa nachfolgendes Ergebnis zurück liefern: | sollte nun in etwa nachfolgendes Ergebnis zurück liefern: | ||
- | Directory Listing: Builds - FooterMilter | + | {{: |
tachtler/gitlab_centos_7_-_ci_cd.txt · Zuletzt geändert: 2018/12/08 07:48 von klaus