Skip to content

Instantly share code, notes, and snippets.

@rohancme
Last active September 5, 2019 14:54
Show Gist options
  • Save rohancme/ac55b33f01020b0a129460d1422ac940 to your computer and use it in GitHub Desktop.
Save rohancme/ac55b33f01020b0a129460d1422ac940 to your computer and use it in GitHub Desktop.
FROM microsoft/windowsservercore
# Specify a public IP here so the build machine can download slave.jar
ARG BASE_URL
# Specify the internal Kubernetes service IP Address here
ARG JENKINS_JNLP_URL
ARG JENKINS_SECRET
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Install jre and add to PATH
# Do not recommend pushing the image to a public repository due to Oracle's EULA: http://www.oracle.com/technetwork/java/javase/documentation/index.html
RUN wget 'http://javadl.oracle.com/webapps/download/AutoDL?BundleId=210185' -Outfile 'C:\jreinstaller.exe' ; \
Start-Process -filepath C:\jreinstaller.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91" ; \
del C:\jreinstaller.exe
ENV JAVA_HOME c:\\Java\\jre1.8.0_91
RUN setx PATH %PATH%;%JAVA_HOME%\bin
RUN (New-Object System.Net.WebClient).DownloadFile('{0}/jnlpJars/slave.jar' -f $env:BASE_URL, 'slave.jar') ;
ENTRYPOINT C:\Java\jre1.8.0_91\bin\java.exe -jar C:\slave.jar -jnlpUrl $Env:JENKINS_JNLP_URL -secret $Env:JENKINS_SECRET
@GANG-CHEN-1
Copy link

There is a issue when build up this image:

SUCCESS: Specified value was saved.
%JAVA_HOME%\bin : The module '%JAVA_HOME%' could not be loaded. For more
information, run 'Import-Module %JAVA_HOME%'.
At line:1 char:93

  • ... ressPreference = 'SilentlyContinue'; setx PATH %PATH%;%JAVA_HOME%\bin
  •                                                       ~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (%JAVA_HOME%\bin:String) [], Par
      entContainsErrorRecordException
    • FullyQualifiedErrorId : CouldNotAutoLoadModule

The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; setx PATH %PATH%;%JAVA_HOME%\bin' returned a non-zero code: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment