In a bitbucket pipeline, I'm trying to run the command: "kubectl delete job/rolling-update", and tried this:
- step:
name: Delete any previously-existing rolling-update jobs - OK to fail
script:
- set +e
- pipe: atlassian/kubectl-run:1.3.3
variables:
KUBE_CONFIG: $KUBE_CONFIG
KUBECTL_COMMAND: "delete"
KUBECTL_ARGS: "job/rolling-update"
- set -e
- sleep 10
however, the error that I get is this:
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
'-f rsrc.yaml'
'--filename=rsrc.json'
'<resource> <name>'
'<resource>'
✖ kubectl delete failed.
and I thought I was providing the resource as described in the last line.
EDIT: I also tried:
KUBECTL_ARGS: "['job/rolling-update']"
and that didn't work either.
Note that running this command locally works fine, so the problem is with passing the arguments to the pipe command.
Does anyone know how to fix this issue?
While I'm here, it would be nice to have an example of this in the documentation for this pipe instead of giving all examples using only "apply":
https://bitbucket.org/atlassian/kubectl-run/src/master/README.md
Thank you!
Hi @gmlewis ,
Thank you for your question!
Please, provide KUBECTL_ARGS as a YAML list, not as a string:
- step:
name: Delete any previously-existing rolling-update jobs - OK to fail
script:
- pipe: atlassian/kubectl-run:1.3.3
variables:
KUBE_CONFIG: $KUBE_CONFIG
KUBECTL_COMMAND: "delete"
KUBECTL_ARGS:
- "job/rolling-update"
or you could provide full command into KUBECTL_COMMAND:
- step:
name: Delete any previously-existing rolling-update jobs - OK to fail
script:
- set +e
- pipe: atlassian/kubectl-run:1.3.3
variables:
KUBE_CONFIG: $KUBE_CONFIG
KUBECTL_COMMAND: "delete job/rolling-update"
We'll investigate this case to prevent such pipe's behavior and notify you.
Cheers,
Oleksandr Kyrdan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the problem is in the `pipe.py` script on lines 110-111:
result = subprocess.run(['kubectl'] + cmd.split() + list(self.get_variable('KUBECTL_ARGS')) + debug, stdout=sys.stdout)
No matter what I pass in for `KUBECTL_ARGS`, the `list()` Python function is going to dice it up into a list of individual characters, like this:
>>> list("job/rolling-update")
['j', 'o', 'b', '/', 'r', 'o', 'l', 'l', 'i', 'n', 'g', '-', 'u', 'p', 'd', 'a', 't', 'e']
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now that I dug further into the implementation of the Pipe class, I think my description above is not correct. @Oleksandr Kyrdan - I can delete this comment if you would like me to.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.