当我运行CI管道时,我正在用詹金斯(CI,CD,CDP)运行3个管道,最后阶段是激活管道CD(连续部署)的触发器,这会从那里接收参数APP_VERSION
CI(连续集成)PIPE并使用packer
部署实例并运行SERVERSPEC TEST
,但是serverspec
测试失败。
但演示应用程序是通过salstack安装的
奇怪的是,当我运行CD并手动传递参数APP_VERSION
时,此工作!!
这是管道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
}
我已将sbin
PATH
传递给serverspec并且无法正常工作。
编辑:我将代码添加到测试中。
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
此外,我添加了作业管道
#!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"
重复..作业管道中的参数APP_VERSION严格,并且在执行测试之前已安装了demo-app应用。