[英]Codefresh allure report: Test reporter requires CF_BRANCH_TAG_NORMALIZED variable for upload files
設置:
結果:僅當作業一直通過管道運行時,第 3 步才會在標題中顯示消息失敗 如果我手動重新運行作業,則可以正常運行(在這種情況下不執行第 1、2 步)
注意:手動添加該標簽沒有幫助
測試執行管道:
stages: - "clone" - "create" - "run" - "get_results" - "clean_up" steps: clone: title: "Cloning repository" type: "git-clone" repo: "repo/repo" # CF_BRANCH value is auto set when pipeline is triggered revision: "${{CF_BRANCH}}" git: "github" stage: "clone" create: title: "Spin up ec2 server on aws" image: mesosphere/aws-cli working_directory: "${{clone}}" # Running command where code cloned commands: - export AWS_ACCESS_KEY_ID="${{AWS_ACCESS_KEY_ID}}" - export AWS_SECRET_ACCESS_KEY="${{AWS_SECRET_ACCESS_KEY}}" - export AWS_DEFAULT_REGION="${{AWS_REGION}}" - aws cloudformation create-stack --stack-name yourStackName --template-body file://cloudformation.yaml --parameters ParameterKey=keyName,ParameterValue=qaKeys stage: "create" run: title: "Wait for results" image: mesosphere/aws-cli working_directory: "${{clone}}" # Running command where code cloned commands: # wait for results in s3 - apk update - apk upgrade - apk add bash - export AWS_ACCESS_KEY_ID="${{AWS_ACCESS_KEY_ID}}" - export AWS_SECRET_ACCESS_KEY="${{AWS_SECRET_ACCESS_KEY}}" - export AWS_DEFAULT_REGION="${{AWS_REGION}}" - chmod +x ./wait-for-aws.sh - ./wait-for-aws.sh # copy results ojbects from s3 - aws s3 cp s3://${S3_BUCKETNAME}/ ./ --recursive - cp -r -f ./_result_/allure-raw $CF_VOLUME_PATH/allure-results - cat test-result.txt stage: "run" get_results: title: Generate test reporting image: codefresh/cf-docker-test-reporting tag: "${{CF_BRANCH_TAG_NORMALIZED}}" working_directory: '${{CF_VOLUME_PATH}}/' environment: - BUCKET_NAME=yourName - CF_STORAGE_INTEGRATION=integrationName stage: "get_results" clean_up: title: "Remove cf stack and files from s3" image: mesosphere/aws-cli working_directory: "${{clone}}" # Running command where code cloned commands: # wait for results in s3 - apk update - apk upgrade - apk add bash - export AWS_ACCESS_KEY_ID="${{AWS_ACCESS_KEY_ID}}" - export AWS_SECRET_ACCESS_KEY="${{AWS_SECRET_ACCESS_KEY}}" - export AWS_DEFAULT_REGION="${{AWS_REGION}}" # delete stack - aws cloudformation delete-stack --stack-name stackName # remove all files from s3 # - aws s3 rm s3://bucketName --recursive stage: "clean_up"```
在這種情況下,添加 CF_BRANCH_TAG_NORMALIZED 作為標簽將無濟於事。
CF_BRANCH_TAG_NORMALIZED 需要設置為此步驟的環境變量。
看一下codefresh/cf-docker-test-reporting的源碼, https://github.com/codefresh-io/cf-docker-test-reporting/blob/master/config/index.js
env: {
// bucketName - only bucket name, with out subdir path
bucketName: ConfigUtils.getBucketName(),
// bucketSubPath - parsed path to sub folder inside bucket
bucketSubPath: ConfigUtils.getBucketSubPath(),
// originBucketName - origin value that can contain subdir need to use it in some cases
originBucketName: process.env.BUCKET_NAME,
apiKey: process.env.CF_API_KEY,
buildId: process.env.CF_BUILD_ID,
volumePath: process.env.CF_VOLUME_PATH,
branchNormalized: process.env.CF_BRANCH_TAG_NORMALIZED,
storageIntegration: process.env.CF_STORAGE_INTEGRATION,
logLevel: logLevelsMap[process.env.REPORT_LOGGING_LEVEL] || INFO,
sourceReportFolderName: (allureDir || 'allure-results').trim(),
reportDir: ((reportDir || '').trim()) || undefined,
reportIndexFile: ((reportIndexFile || '').trim()) || undefined,
reportWrapDir: _.isNumber(reportWrapDir) ? String(reportWrapDir) : '',
reportType: _.isString(reportType) ? reportType.replace(/[<>]/g, 'hackDetected') : 'default',
allureDir,
clearTestReport
},
您可以看到 CF_BRANCH_TAG_NORMALIZED 直接取自環境。
我的假設是,通常觸發您的構建的任何東西都不會設置此環境變量。 它通常在您有 git 觸發器時自動設置,例如來自 Github。 當您手動啟動管道時,您可能會設置變量,這就是它運行的原因。
您應該檢查通常如何觸發管道以及是否設置了變量(自動或手動)。
以下是有關這些變量的更多文檔: https://codefresh.io/docs/docs/codefresh-yaml/variables/#system-provided-variables
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.