From 50b2612a5f8cad95d4f1f5d7a67ec7d279a88789 Mon Sep 17 00:00:00 2001
From: "gioacchino.vino" <gioacchino.vino@infn.it>
Date: Wed, 27 Sep 2023 09:33:33 +0200
Subject: [PATCH] Added greenbone check

---
 jenkinsfile/Jenkinsfile | 42 +++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/jenkinsfile/Jenkinsfile b/jenkinsfile/Jenkinsfile
index 6068820..1337209 100644
--- a/jenkinsfile/Jenkinsfile
+++ b/jenkinsfile/Jenkinsfile
@@ -9,27 +9,33 @@ pipeline {
     stages {
         stage ('Test environment'){
             steps {
-                sh '''#!/bin/bash
-                    eval `oidc-agent-service use`
-                    oidc-add infn-cloud-ops
-                    
-                    env
+                withCredentials([
+                    usernamePassword(credentialsId: "jenkins_scans_creds", usernameVariable: 'GMP_USER', passwordVariable: 'GMP_PASSWORD')
+                ]) {
+                    sh '''#!/bin/bash
+                        eval `oidc-agent-service use`
+                        oidc-add infn-cloud-ops
+                        
+                        env
 
-                    # Orchent connection test
-                    orchent depls > depls.output
-                    if cat depls.output | grep -q ERROR
-                    then 
-                        echo "orchent depls: NOT ok" 
-                        cat depls.output 
-                        exit 1
-                    else 
-                        echo "orchent depls: ok" 
-                    fi
+                        # Orchent connection test
+                        orchent depls > depls.output
+                        if cat depls.output | grep -q ERROR
+                        then 
+                            echo "orchent depls: NOT ok" 
+                            cat depls.output 
+                            exit 1
+                        else 
+                            echo "orchent depls: ok" 
+                        fi
 
-                    # Greenbone connection test
-                    /var/lib/jenkins/.local/bin/gvm-cli --gmp-username $GMP_USERNAME --gmp-password $GMP_PASSWD tls --hostname $HOST_IP --xml "<get_version/>"
+                        which gvm-cli
 
-                '''
+                        # Greenbone connection test
+                        /var/lib/jenkins/.local/bin/gvm-cli --gmp-username $GMP_USERNAME --gmp-password $GMP_PASSWD tls --hostname $HOST_IP --xml "<get_version/>"
+
+                    '''
+                }
             }
         }
         stage ('Create test deployment'){
-- 
GitLab