Execute powershell command on successful build?

I’m very new to this environment so please forgive me if this has been asked. I tried searching and didn’t see anything.

I’m trying to figure out if there is a way to have a powershell command automatically execute if my firmware compiles/builds successfully.

Basically I have a 3D printer hooked up to octoprint which is a little linux box. I just need to get firmware.bin over to the sdcard in my printer. So I have a single line script that runs scp and sends the file over. I’m hoping to just have that run if the build is successful. Is this possible?


1 Like

Welcome to the community!

My installation is somewhat fubared right now so I can’t test this, but I believe your answer lies in this documentation:

In your platformio.ini file use the following:

extra_scripts = post:extra_script.py

extra_script.py should be in the same directory as your platformio.ini file.


Thank you so much!!

I will have to brush up on my python but getting it to run a simple bash script shouldn’t be too hard :slight_smile:

Happy to help. There’s a lot of information in the documentation, but sometimes finding a simple “hello world” solution for things is challenging. I love the environment and the folks here are great - still, I’m learning a little each day.

1 Like
import os
os.system('powershell.exe [myscript.ps1]')

In that extra_script should do the trick …

Or if you want to get real fancy, you could override the default upload target, so that build just builds, but upload builds and then uploads if successful…

1 Like