Windows environment variables, user, Jenkins working path

A, command path

New Folder command in the C drive, create a new file in the command demonstration.bat, add the file echo This is demonstration.bat. Open cmd, execute the following command and see the results:

C:UsersAdministrator>cd C:command

C:command>demonstration.bat
This is demonstration.bat

C:command>cd ..

C:>demonstration.bat
'demonstration.bat' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:>C:commanddemonstration.bat
This is demonstration.bat

The resulting experience: 1, the command searches for the executable file in the current path without paths. 2, when the current path command with no effect on the path.

Second, the environment variable, restart

New user variable , the variable name DemonstrationPath, variable value C: command. carried out:

C:>echo %DemonstrationPath%
%DemonstrationPath%

C:>%DemonstrationPath%demonstration.bat
系统找不到指定路径

Restart cmd, execute:

C:UsersAdministrator>echo %DemonstrationPath%
C:command

C:UsersAdministrator>%DemonstrationPath%demonstration.bat
This is demonstration.bat

The resulting experience: Open cmd modify environment variables, environment variables do not take effect in open cmd in.

Third, environment variables, user variables and system variables

Create a windows user, the user name testerhome, switch users to testerhome. carried out:

C:Userstesterhome>whoami
win-716fc3ul8mltesterhome

C:Userstesterhome>echo %DemonstrationPath%
%DemonstrationPath%

C:Userstesterhome>%DemonstrationPath%demonstration.bat
系统找不到指定的路径。

Administrator user to switch to. Delete user variables DemonstrationPath, the new system variable , the variable name DemonstrationPath, variable value C: command, restart cmd. carried out:

C:UsersAdministrator>whoami
win-716fc3ul8mladministrator

C:UsersAdministrator>echo %DemonstrationPath%
C:command

C:UsersAdministrator>%DemonstrationPath%demonstration.bat
This is demonstration.bat

Testerhome user switch to restart cmd. carried out:

C:Userstesterhome>whoami
win-716fc3ul8mltesterhome

C:Userstesterhome>echo %DemonstrationPath%
C:command

C:Userstesterhome>%DemonstrationPath%demonstration.bat
This is demonstration.bat

Administrator user to handover, the new user variable , the variable name DemonstrationPath, the value of the variable C:, restart cmd. carried out:

C:UsersAdministrator>echo %DemonstrationPath%
C:

C:UsersAdministrator>%DemonstrationPath%demonstration.bat
'C:demonstration.bat' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

The resulting experience: 1, different Windows users to use their own user variables . 2, different users use the same Windows system variables . 3, the same name system variables and user variables , the precedence user variable .

Fourth, the system variable Path

In cmd execution:

C:UsersAdministrator>demonstration.bat
'demonstration.bat' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

View System variables Path, after the variables have been added;% DemonstrationPath%, restart cmd. carried out:

C:UsersAdministrator>demonstration.bat
This is demonstration.bat

C:UsersAdministrator>D:

D:>demonstration.bat
This is demonstration.bat

The resulting experience: command without the executable file in the search path ** and ** Path Path Path variable values ​​in the current.

Five, Jenkins belongs to the working path and Windows users

Download Jenkins.war executed after java -jar jenkins.warstarting Jenkins services. After a successful start to add a Windows system variable, the variable name Restart, variable values ThisIsRestart. In Jenkins in the new free-style software project, Item name survey, increased building steps Execute Windows batch command, fill in:

echo %Restart%

Building immediately after the save, view Console Output:

C:UsersAdministrator.jenkinsjobssurveyworkspace>echo
ECHO 处于打开状态。

Jenkins restart the service, immediately building survey, view the Console Output:

C:UsersAdministrator.jenkinsjobssurveyworkspace>echo ThisIsRestart
ThisIsRestart

Modify survey build command:

whoami

After saving the building immediately, see Console Output, some of which reads:

C:UsersAdministrator.jenkinsjobssurveyworkspace>whoami
heishui-pcAdministrator

Close cmd window opens Jenkins services, Windows users to switch to testerhome, execution java -jar jenkins.warstarts Jenkins services. The new free-style software project, Item name survey, increased building steps Execute Windows batch command, fill in:

whoami

After saving the building immediately, see Console Output, some of which reads:

C:Userstesterhome.jenkinsjobssurveyworkspace>whoami
heishui-pctesterhome

Configuring survey, senior project options - use a custom workspace, enter the directory D: workspace, building survey immediately after save, view the Console Output.

D:workspace>whoami
heishui-pctesterhome

The resulting experience: 1, modified after starting Jenkins environment variables to take effect after the restart Jenkins. 2, the default is the working path Jenkins: Jenkins System Management - System Settings - Home Directory + .jenkinsjobs + Item Name Workspace + . 3, you can configure their work paths to different projects.

Six, Jenkins system settings of the JDK and Maven

Installation JDK7 and JDK8, Windows environment variable configuration to JDK7. Decompression Maven3.3.3 and Maven3.2.5, Windows environment variable configuration to Maven3.3.3. Cancel workspace using tick survey of custom modify the build command is:

echo %JAVA_HOME%
java -version
echo %MAVEN_HOME%
mvn -v

Building immediately after the save, view Console Output:

C:Userstesterhome.jenkinsjobssurveyworkspace>echo C:Program Files (x86)Javajdk1.7.0_79 
C:Program Files (x86)Javajdk1.7.0_79

C:Userstesterhome.jenkinsjobssurveyworkspace>java -version 
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode, sharing)

C:Userstesterhome.jenkinsjobssurveyworkspace>echo D:Program Filesapache-maven-3.3.3bin 
D:Program Filesapache-maven-3.3.3bin

C:Userstesterhome.jenkinsjobssurveyworkspace>mvn -v 
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00)
Maven home: D:Program Filesapache-maven-3.3.3bin..
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: C:Program Files (x86)Javajdk1.7.0_79jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

In Jenkins Management System - system settings, the new JDK, uncheck the automatic installation, fill in the path JDK8 in JAVA_HOME. New Maven, uncheck the automatic installation, fill maven3.2.5 in MAVEN_HOME path. Building survey immediately after save, view the Console Output:

C:Userstesterhome.jenkinsjobssurveyworkspace>echo C:Program FilesJavajdk1.8.0_51 
C:Program FilesJavajdk1.8.0_51

C:Userstesterhome.jenkinsjobssurveyworkspace>java -version 
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

C:Userstesterhome.jenkinsjobssurveyworkspace>echo D:Program Filesapache-maven-3.3.3bin 
D:Program Filesapache-maven-3.3.3bin

C:Userstesterhome.jenkinsjobssurveyworkspace>mvn -v 
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00)
Maven home: D:Program Filesapache-maven-3.3.3bin..
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: C:Program FilesJavajdk1.8.0_51jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

New project to build a maven project, Item name MavenSurvey, increase Pre Steps - Execute Windows batch command, fill in:

echo %JAVA_HOME%
java -version
echo %MAVEN_HOME%
mvn -v

Construction of MavenSurvey immediately after save, view the Console Output:

C:Userstesterhome.jenkinsjobsMavenSurveyworkspace>echo C:Program FilesJavajdk1.8.0_51 
C:Program FilesJavajdk1.8.0_51

C:Userstesterhome.jenkinsjobsMavenSurveyworkspace>java -version 
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

C:Userstesterhome.jenkinsjobsMavenSurveyworkspace>echo D:Program Filesapache-maven-3.2.5 
D:Program Filesapache-maven-3.2.5

C:Userstesterhome.jenkinsjobsMavenSurveyworkspace>mvn -v 
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00)
Maven home: D:Program Filesapache-maven-3.2.5
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: C:Program FilesJavajdk1.8.0_51jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

The resulting experience: 1, free-style project, JDK path Jenkins priority use system settings, Maven using the Windows path environment variable. 2, Maven project, JDK path Jenkins preferentially used in the system settings, Maven path preferentially used Jenkins system settings.


Til next time,
Blackwater at 09:46

scribble

Original: Big Box  Windows environment variables, user, Jenkins working path


Guess you like

Origin www.cnblogs.com/chinatrump/p/11607418.html