-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defining environment variables is not clear #617
Comments
Great note, I also ran into this. I dug into BasePipelineTest.groovy and found there is an I've updated the example to use
import com.lesfurets.jenkins.unit.BasePipelineTest
class TestExampleJob extends BasePipelineTest {
@Override
@BeforeEach
void setUp() {
super.setUp()
// Define environment variable
addEnvVar('MY_ENV_VAR', '0')
// Assigns false to a job parameter ENABLE_TEST_STAGE
addParam('ENABLE_TEST_STAGE', 'false')
// Defines the previous execution status
binding.getVariable('currentBuild').previousBuild = [result: 'UNSTABLE']
// Define Jenkins global variable
binding.setVariable('RUN_DISPLAY_URL', 'https://jenkins.io')
}
@Test
void verifyParam() {
assertEquals('false', binding.getVariable('params')['ENABLE_TEST_STAGE'])
}
} I can make a pull request with some docs improvements when I have time. I'm loving this project! 😄🙏 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe your use-case which is not covered by existing documentation.
In the documentation inside the README we have:
JenkinsPipelineUnit/README.md
Lines 151 to 172 in c8fa326
How does this cover setting environment variables? For me, it seems like this will only set a parameter/params value, but no env one. Playing around with it seems to be indicate that this might be achieved by using
binding.getVariable('env').newValue = 'test'
, but it might make sense to actually document this as well.Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.
No response
The text was updated successfully, but these errors were encountered: