Reputation: 1736
I want to use the $CI_ENVIRONMENT_SLUG
to point our Selenium tests to the right dynamic environment, but the variable is empty.
During the deployment stage it has a proper value and I don't get why the variable is not available in every stage. The echo
cmd prints an empty line.
Tests:
image: maven:3.5.0-jdk-8
stage: Tests and static code checks
variables:
QA_PUBLISH_URL: http://$CI_ENVIRONMENT_SLUG-publish.test.com
script:
- echo $QA_PUBLISH_URL
- echo $CI_ENVIRONMENT_SLUG # empty
- mvn clean -Dmaven.repo.local=../../.m2/repository -B -s ../../settings.xml -P testrunner install -DExecutionID="FF_LARGE_WINDOWS10" -DRunMode="desktopLocal" -DSeleniumServerURL="https://$QA_ZALENIUM_USER:[email protected]/wd/hub" -Dcucumber.options="--tags @sanity" -DJenkinsEnv="test.com" -DSeleniumSauce="No" -DBaseUrl=$QA_PUBLISH_URL
Upvotes: 5
Views: 6349
Reputation: 1703
CI_ENVIRONMENT_SLUG
is only available in the review JOB that has the environment set.
And currently (11.2) there is no way to move variables from one JOB to another, although you could:
echo -e -n "$CI_ENVIRONMENT_SLUG" > ci_environment_slug.txt
in the review JOB and add the file to the artifacts:
artifacts:
paths:
- ci_environment_slug.txt
and in your Tests
job, use
before_script:
- export CI_ENVIRONMENT_SLUG=$(cat ci_environment_slug.txt)
Upvotes: 6