Hi!
I have a problem with Starlark runner somehow caching the input parameters.
My goal is to generate a set of similar pipelines based on the input parameters provided from outside. I’m doing that with Starlark.
And I have noticed that when I kick off several builds for the same branch/commit but with different parameters, drone would cache the first one, and the consequent builds would not be affected by the parameters change.
My .drone.star file looks like this (for demonstartion purposes):
def main(ctx):
return generate_test_pipelines(ctx)
def generate_test_pipelines(ctx):
params = ctx.build.params
release_names = params.get("RELEASE_NAMES", "").split(",")
pipelines = []
for release_name in release_names:
pipelines.append(create_test_pipeline(release_name, params))
return pipelines
def create_test_pipeline(name, params):
return {
"kind": "pipeline",
"type": "docker",
"name": name,
"platform": {
"os": "linux",
"arch": "amd64"
},
"trigger": {
"event": ["custom"]
},
"steps": [
{
"name": "log-all-params",
"image": "bash",
"commands": [
"echo params are '%s'" % (params),
"echo $RELEASE_NAMES"
]
}
]
}
I kick off builds from CLI like this:
# Number 1
curl -X POST -G \
https://drone-gf.company.com/api/repos/Livit/Livit.Learn.Selenium/builds \
-H "Authorization: Bearer SECRET" \
--data-urlencode 'branch=test-starlark-params' \
--data-urlencode 'TEST_A=FOO' \
--data-urlencode 'TEST_B=BAR' \
--data-urlencode 'RELEASE_NAMES=ACB,ELE,LSC,HOM'
# Number 2, notice the parameters change
curl -X POST -G \
https://drone.company.com/api/repos/Livit/Livit.Learn.Selenium/builds \
-H "Authorization: Bearer SECRET" \
--data-urlencode 'branch=test-starlark-params' \
--data-urlencode 'TEST_A=FOO1' \
--data-urlencode 'TEST_B=BAR1' \
--data-urlencode 'RELEASE_NAMES=ACB,ELE'
Below are the screenshots, you can see that the server response contains the correct values which means its not web server caching smth. (The first call log got stripped when I changed the window size, but the main thing is visible)
The first build looks right, but the second is exactly same even though the parameters are different.
Also notice echo $RELEASE_NAMES
command produces the right output.
This looks like there’s a bug at the time of YAML generation from Starlark.