How can I change my PATH variable on a windows machine to add a new path ?
I have seen this post but it does not talk about windows.
I have tried - run: setx path "C:\Users\circleci\XX"
but it does not work
I am currently using these :
executors:
windows:
machine:
image: windows-server-2019
resource_class: windows.medium
shell: cmd.exe
orbs:
windows: circleci/windows@1.0.0
2 Likes
@fabiencelier in the meantime, did you get it to work?
So, for my own integration sceanios, I found:
cmd.exe calls in config.yml are extremely limited!
Your best option there is to just direct the call to a script…
version: 2.1
references:
workspace_root: &workspace_root "C:\\Users\\circleci\\project"
orbs:
win: circleci/windows@2.2.0
jobs:
test_job:
executor: win/default
working_directory: *workspace_root
steps:
- checkout
- run:
name: "Run PATH changing script"
shell: cmd.exe
command: cd path_test & modifyPathAndCallScript.bat
workflows:
test_workflow:
jobs:
- test_job
…and do everything you need inside that script, e.g. PATH manipulation like this: (file [repo]/path_test/modifyPathAndCallScript.bat )
@ECHO OFF
ECHO.Changing PATH to include subdirectory
ECHO.Current PATH is '%PATH%'
REM Calls cd without arguments to get the current directory
SET current_directory=%cd%
SET PATH=%PATH%;%current_directory%\add_me_to_path_variable
ECHO.Changed PATH is '%PATH%'
call shouldBeFoundFromPath
IF ERRORLEVEL 1 (
ECHO.The error level was at least 1 - exiting...
SET /P var=Press Enter to exit
EXIT /B 1
)
SET /P var=Press Enter to exit
@ECHO ON
My file [repo]/path_test/add_me_to_path_variable/shouldBeFoundFromPath.bat looks like this:
@ECHO OFF
ECHO.#####################################
ECHO.Script was called from PATH!
ECHO.PATH is '%PATH%'
ECHO.#####################################
EXIT /B 0
@ECHO ON
Be careful: When setting PATH, don’t add any ’ or " where they don’t have to be, that broke everything for me.