Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I run "kubectl delete job/rolling-update" in a Bitbucket pipeline? Edited

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!

2 answers

1 accepted

2 votes
Answer accepted

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

Like Oleksandr Kyrdan likes this

I think the problem is in the `pipe.py` script on lines 110-111:

https://bitbucket.org/atlassian/kubectl-run/src/e53754cb58a4b473d63547da7cca4b86d577505a/pipe/pipe.py#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']

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

⚡️NEW Group for Confluence Cloud Admins

Calling all Confluence Cloud Admins!  We created a new Community Group to support your unique needs as Confluence admins. This is a group where you can ask questions, access resou...

69 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you