#!/usr/bin/env groovy pipeline { agent { kubernetes { label "k8s-build-${cto.devops.jenkins.Utils.getTimestamp()}" inheritFrom 'k8s-dind-rootless' defaultContainer 'tools' yaml cciContainers([[ name: 'buildanchore', image: "~/buildah_tools:latest"]]) } } options { timeout(time: 180, unit: 'MINUTES') buildDiscarder(logRotator(daysToKeepStr: '30', artifactDaysToKeepStr: '30')) timestamps() } environment { ~ } stages{ stage('Fetch_image_list') { steps { container('tools') { withCredentials([usernamePassword(credentialsId: 'abc', passwordVariable: 'pwd', usernameVariable: 'user')]) { sh ''' touch file touch file2 touch file3 wget ${QCOW2_PATH}/${QCOW} pwd ls -lhr ls -l docker ps -a docker pull --quiet ${IMAGE}:latest docker images docker run -t --name guestfs_container -w /workdir -v ${WORKSPACE}:/workdir -e file=${QCOW} --entrypoint bash registry1-docker-io.repo.lab.pl.alcatel-lucent.com/djui/guestfs -xec ' ls -lhr / pwd ls -lhr export LIBGUESTFS_TRACE=1 export LIBGUESTFS_DEBUG=1 eval $(guestfish --listen) if [ -z "${GUESTFISH_PID}" ]; then echo "Error mounting image." exit 1 fi guestfish --remote -- add-ro $file guestfish --remote -- run virt_filesystems="$(guestfish --remote -- list-filesystems | grep "ext" | grep "sda2" | cut -d: -f1)" pwd df -h guestfish --remote -- mount ${virt_filesystems} / guestfish --remote -- ls / guestfish --remote -- mkdir-p /docker guestfish --remote -- copy-in file /docker guestfish --remote -- copy-in file2 /docker guestfish --remote -- copy-in file3 /docker guestfish --remote -- ls / guestfish --remote -- ls /docker guestfish --remote -- unmount / guestfish --remote -- exit ls -l ' docker ps -a docker images docker stop guestfs_container DOC_ID=$(docker ps -aqf "name=guestfs_container") docker commit $DOC_ID guestfs_container2 # path=$(pwd) docker ps -a docker images docker run -t -w /workdir -v ${WORKSPACE}:/workdir -e file=${QCOW} --entrypoint bash guestfs_container2 -xec ' pwd ls -lhr ls -lhr / export LIBGUESTFS_TRACE=1 export LIBGUESTFS_DEBUG=1 eval $(guestfish --listen) if [ -z "${GUESTFISH_PID}" ]; then echo "Error mounting image." exit 1 fi guestfish --remote add-ro $file guestfish --remote run virt_filesystems="$(guestfish --remote list-filesystems | grep "ext" | grep "sda2" | cut -d: -f1)" pwd df -h guestfish --remote mount ${virt_filesystems} / guestfish --remote ls / guestfish --remote ls /docker guestfish --remote exit ' ''' } } } } } }