diff --git a/Jenkinsfile b/Jenkinsfile index 0fde8aa79b66c505f5a39c2d595b6971c61cb932..b99af36d62d7f9115eeb0579c3498d5c474ee12d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,9 +26,31 @@ pipeline { } // steps } // stage - stage('OpenSCAP Compliance Scan (TODO)') { - steps { + stage('OpenSCAP Compliance Scan (TODO)') { + steps { echo 'OpenSCAP Compliance Scan' + script { + def remote = [:] + remote.name = "node" + remote.host = "ec2-52-222-64-188.us-gov-west-1.compute.amazonaws.com" + remote.allowAnyHosts = true + node { + withCredentials([sshUserPrivateKey(credentialsId: 'oscap', keyFileVariable: 'identity', usernameVariable: 'userName')]) { + remote.user = userName + remote.identityFile = identity + stage('SSH to OpenSCAP Node') { + sshCommand remote: remote, command: "sudo docker pull nexus-docker.us-gov-west-1.compute.internal/up/openjdk:latest" + sshCommand remote: remote, command: "sudo oscap-docker image nexus-docker.us-gov-west-1.compute.internal/up/openjdk:latest xccdf eval --profile xccdf_org.ssgproject.content_profile_stig-rhel7-disa --report report.html /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml" + sshCommand remote: remote, command: "sudo oscap-docker image-cve nexus-docker.us-gov-west-1.compute.internal/up/openjdk:latest --report report-cve.html" + sshGet remote: remote, from: "/home/ec2-user/report.html", into: '/var/lib/jenkins/jobs/oscap-test/workspace/openscap-compliance-report.html', override: true + sshGet remote: remote, from: "/home/ec2-user/report-cve.html", into: '/var/lib/jenkins/jobs/oscap-test/workspace/openscap-cve-report.html', override: true + publishHTML([alwaysLinkToLastBuild: false, keepAll: false, reportDir: '/var/lib/jenkins/jobs/oscap-test/workspace/', reportFiles: 'openscap-compliance-report.html', reportName: 'OpenSCAP Compliance Report', reportTitles: 'OpenSCAP Compliance Report']) + publishHTML([alwaysLinkToLastBuild: false, keepAll: false, reportDir: '/var/lib/jenkins/jobs/oscap-test/workspace/', reportFiles: 'openscap-cve-report.html', reportName: 'OpenSCAP Vulnerability Report', reportTitles: 'OpenSCAP Vulnerability Report']) + // archiveArtifacts '/var/lib/jenkins/jobs/oscap-test/workspace/openscap-compliance-report.html' + } // script + } // stage + } // withCredentials + } //node } // steps } // stage