Windows worker with java 1.8 and maven


#1

Hey guys,

Can’t find anywhere this has been answered, wondering if it has been done before or how I could go about this.

I have concourse installed as a cluster via this bosh release

I setup my windows worker using the windows worker operation from this repository

I have both a spring boot application and a library (compiled with maven).

My job task is setup as such (mostly because it was the only way I could get windows to work) :

- name: windows-unit-test
  plan:
  - aggregate: 
    - get: Remediation
      trigger: true
    - get: java-for-windows
    - get: maven-for-windows
  - task: test
    config:
      platform: windows
      inputs:
      - name: Remediation
      - name: java-for-windows
      - name: maven-for-windows
      run:
        path: Remediation/ci/tasks/acceptanceTests.bat

and the resources/types I have are:

resource_types:
- name: git-windows
  type: docker-image
  source:
    repository: cpwilliams/git-windows-concourse-resource
    tag: latest
- name: file-url
  type: docker-image
  source:
    repository: pivotalservices/concourse-curl-resource
    tag: latest

resources:
- name: Remediation
  type: git
  source:
    branch: master
    private_key: ((remediation.github_private_key))
    uri: ((remediation.github_uri))
    ignore_paths: 
      - number

## WINDOWS WORKER RESOURCES ###
- name: java-for-windows
  type: file-url
  source:
    url: http://javadl.oracle.com/webapps/download/AutoDL?BundleId=235725_2787e4a523244c269598db4e85c51e0c
    filename: jre-8u191-windows-i586.exe

- name: maven-for-windows
  type: file-url
  source:
    url: http://apache.mirrors.lucidnetworks.net/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip
    filename: apache-maven-3.5.4-bin.zip

I doubt installing java and maven from a bat script is the right way to go about this and I’m looking for guidance as there is probably a better way to do this.

Is there a better way to have a windows worker with java 1.8 and maven setup so I don’t have to install them with every execution? I also have not successfully figured out how to install these things from a headless cmd prompt but that’s a different struggle.

Thanks in advanced for any pointers or suggestions.


#2

hi thecpdubguy,

Concourse runs your Ci Tasks in Docker containers. You can specify your own docker image for this Container
and refer to it from Dockerhub.

@checkout https://concourse-ci.org/tasks.html#task-image-resource

Provide your own Docker image with Maven and Java in the desired version. Concourse tasks also have a tag option for images where you can specify which version of your image shall be used. This can be useful if you plan to update the Java / Maven versions at some point.

best,
D


#3

Hi gdenn,

I tried using a docker image for the task but the job exited with the error unsupported resource type

My old configuration was:

 - name: windows-unit-test
   plan:
   - get: Remediation
     trigger: true
   - task: test
     config:
       platform: windows
       image_resource:
         type: docker-image
         source:
           repository: ((windows_docker_repo))
           tag: ((windows_docker_repo_version))
       inputs:
       - name: Remediation
       run:
         path: Remediation/ci/tasks/acceptanceTests.bat

Is there another image_resource.type I could use for this? I haven’t been able to find a list of supported image_resource types.

Thanks


#4

Note that Concourse runs tasks in containers only on Linux. If you need to build on Windows or on Mac, you have to build on the host itself. I assume that, since you are trying to setup a Windows worker, you do need Windows (although you are building Java).

Regarding

Is there a better way to have a windows worker with java 1.8 and maven setup so I don’t have to install them with every execution?

Yes there is :-), although it is independent from Concourse. You have to provision the Windows worker before hand.

Since you are using BOSH (I am not familiar with that), you have to understand how to build a Windows image useable by BOSH, run scripts/ansible/similar to install your tools and then feed it to BOSH. That would be the best, since you would get what is called “immutable infrastructure”: the Windows BOSH image is pre-backed with your build tools.

Another option (but really I am speculating here because I don’t know how BOSH can be interfaced with) is, once the Windows image is spawned, run out-of-band a provisioner like Ansible. This is less ideal than a pre-backed image and less robust (it will drift), but it might be simpler to get it working if all this is new to you.

There is another bizarre configuration in your pipeline, the cpwilliams/git-windows-concourse-resource, I don’t understand it.

A Concourse deployment needs at least a Linux worker, because ALL the resources are containers and so need Linux. Once you have it, you can use the built-in git resource, no need to use bizarre things like that, you can just follow the examples on how to refer to a git repo.