We have a pipeline that can be promoted to a few different envs/targets. If a build is promoted to 2 envs one by one, context.build.environment value is the same on each promote.
Steps to reproduce:
- Create the following buildspec:
def main(ctx):
return [
promote_pipeline(ctx),
test_pipeline(),
]
def promote_pipeline(ctx):
env = ctx.build.environment
return {
'kind': 'pipeline',
'name': 'promote/rollback build pipeline',
'steps': [
{
'name': 'name env we are promoting to',
'image': 'alpine',
'commands': [
'echo "promoting {}"'.format(env),
],
}
],
'trigger': {
'event': ['promote'],
'target': [
'staging',
'uat',
'prod',
]
}
}
def test_pipeline():
return {
'kind': 'pipeline',
'name': 'testing pipeline',
'steps': [
{
'name': 'say hello',
'image': 'alpine',
'commands': [
'echo "HELLO WORLD!"',
],
}
],
'trigger': {
'branch': ['master']
}
}
- Promote the build from step 1 to uat
- Promote the build from step 1 to prod
Expected result:
- –
- promote/rollback build pipeline output: promoting uat
- promote/rollback build pipeline output: promoting prod
Actual result:
- –
- promote/rollback build pipeline output: promoting uat
- promote/rollback build pipeline output: promoting uat
For some reason Drone preserves context.build.environment value from previous promote event. Can be fixed by a drone-server container restart.