[Jenkins]Batch Command로 네트워크 드라이브 접근

Jenkins에서 Execute Windows Batch Command를 이용해서 네트워크에 접근하려고 하면
에러가 발생한다.

Network drive mappings (Windows)

On Windows, network drive mappings are scoped to users. So if you run Jenkins in a different user account (such as a Windows service), they will not see the same drive mapping that you do. Use UNC notation (//server/path/to/file), or refer toHow to get command prompt as the SYSTEM user and start a command prompt, then define drive mappings.

사용자 계정 문제 때문에 이러한 에러가 발생하게 되는데, 이것을 해결하기 위해서는 네트워크 드라이브를 연결할 때, NT AUTHORITY\SYSTEM 계정으로 등록을 해야한다. 등록하는 방법은 아래와 같다.
1. psexec를 C드라이브(C:\)에 다운로드 받는다.
2. cmd(명령 프롬프트)를 관리자 권한으로 실행한다.
3. cd C:\ 입력
4. psexec -i -s cmd.exe 입력
(* whoami 를 입력해서 nt authority\system가 나온다면 정상이다.)
5. net use Z: \\servername_OR_IP\sharedfolder /u:username /persistent:yes

위 과정을 수행한 뒤에 다시 Jenkins에서 Z: 드라이브에 접근하면 오류 없이 접근할 수 있다.

댓글

이 블로그의 인기 게시물

[Jenkins] Slave 노드 연결하기.

영어 표현 공부 - Fawn over