Serverspec test fail when i run its pipeline from other pipeline

58 Views Asked by At

I'm running 3 pipelines in jenkins (CI, CD, CDP) when I run the CI pipe the final stage is a trigger for activate the pipe CD (Continuous Deployment), this receive a parameter APP_VERSION from CI (Continuous Integration) PIPE and deploy an instance with packer and run SERVERSPEC TEST, but serverspec test failed.

enter image description here

but the demo-app is installed via salstack

Image 2

The strange is when I run the CD and pass the parameter APP_VERSION manually this WORK !!

this is the final stage for pipeline CI

stage "Trigger downstream"
    echo 'parametro'
    def versionApp = sh returnStdout: true, script:"echo \$(git rev-parse --short HEAD) "
    build job: "demo-pipeCD", parameters: [[$class: "StringParameterValue", name: "APP_VERSION", value: "${versionApp}"]], wait: false
}

I have passed to serverspec the sbin PATH and not work.

EDIT: I add the code the test.

enter code here

require 'spec_helper'

versionFile = open('/tmp/APP_VERSION')
appVersion = versionFile.read.chomp

describe package("demo-app-#{appVersion}") do
it { should be_installed }
end

Also, i add the job pipeline

#!groovy

node {

step([$class: 'WsCleanup'])

stage "Checkout Git repo"
checkout scm

stage "Checkout additional repos"
dir("pipeCD") {
  git "https://git-codecommit.us-east- 
 1.amazonaws.com/v1/repos/pipeCD"
}

stage "Run Packer"
sh "echo $APP_VERSION"
sh "\$(export PATH=/usr/bin:/root/bin:/usr/local/bin:/sbin)"
sh "/opt/packer validate -var=\"appVersion=$APP_VERSION\" -var- 
file=packer/demo-app_vars.json packer/demo-app.json"
sh "/opt/packer build -machine-readable - 
var=\"appVersion=$APP_VERSION\" -var-file=packer/demo-app_vars.json 
packer/demo-app.json | tee packer/packer.log"

REPEAT .. the parameter APP_VERSION in job pipe is rigth and the demo-app app is installed before the execute the test.

0

There are 0 best solutions below