Skip to content

Commit

Permalink
Add Proxies and use Script for maven tasks
Browse files Browse the repository at this point in the history
Signed-off-by: vinamra28 <vinjain@redhat.com>
  • Loading branch information
vinamra28 authored and tekton-robot committed Mar 20, 2020
1 parent d5bf0f7 commit 86f50bc
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 41 deletions.
64 changes: 58 additions & 6 deletions maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/maven
### Parameters

- **GOALS**: Maven `goals` to be executed
- **MAVEN_MIRROR_URL**: Maven mirror url (to be inserted into ~/.m2/settings.xml)
- **MAVEN_MIRROR_URL**: Maven mirror url (to be inserted into ~/.m2/settings.xml)
- **PROXY_USER**: Username to login to the proxy server (to be inserted into ~/.m2/settings.xml)
- **PROXY_PASSWORD**: Password to login to the proxy server (to be inserted into ~/.m2/settings.xml)
- **PROXY_HOST**: Hostname of the proxy server (to be inserted into ~/.m2/settings.xml)
- **NON_PROXY_HOST**: Non proxy hosts to be reached directly bypassing the proxy (to be inserted into ~/.m2/settings.xml)
- **PROXY_PORT**: Port number on which the proxy port listens (to be inserted into ~/.m2/settings.xml)
- **PROXY_PROTOCOL**: http or https protocol whichever is applicable (to be inserted into ~/.m2/settings.xml)

### Resources

Expand Down Expand Up @@ -71,6 +77,18 @@ spec:
params:
- name: MAVEN_MIRROR_URL
value: "http://localhost:8080/bucketrepo/"
- name: PROXY_HOST
value: "proxy.somewhere.com"
- name: PROXY_PORT
value: "8080"
- name: PROXY_USER
value: "yourusername"
- name: PROXY_PASSWORD
value: "yourpassword"
- name: NON_PROXY_HOST
value: "www.google.com|*.example.com"
- name: PROXY_PROTOCOL
value: "https"
taskRef:
name: maven
```
Expand Down Expand Up @@ -103,6 +121,30 @@ spec:
description: The Maven bucketrepo- mirror
type: string
default: ""
- name: PROXY_USER
description: The username for the proxy server
type: string
default: "testuser"
- name: PROXY_PASSWORD
description: The password for the proxy server
type: string
default: "testpassword"
- name: PROXY_PORT
description: Port number for the proxy server
type: string
default: "80"
- name: PROXY_HOST
description: Proxy server Host
type: string
default: ""
- name: NON_PROXY_HOST
description: Non proxy server host
type: string
default: ""
- name: PROXY_PROTOCOL
description: Protocol for the proxy ie http or https
type: string
default: "http"
resources:
- name: source
targetPath: /
Expand All @@ -111,11 +153,9 @@ spec:
- name: mvn-settings
image: registry.access.redhat.com/ubi8/ubi-minimal:latest
workingDir: /.m2
command:
- '/bin/bash'
- '-c'
args:
- |-
script: |
#!/usr/bin/env bash
[[ -f /.m2/settings.xml ]] && \
echo 'using already existing /.m2/settings.xml' && \
cat /.m2/settings.xml && exit 0
Expand All @@ -131,6 +171,18 @@ spec:
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<proxies>
<proxy>
<id>proxy.default</id>
<active>true</active>
<protocol>$(inputs.params.PROXY_PROTOCOL)</protocol>
<username>$(inputs.params.PROXY_USER)</username>
<password>$(inputs.params.PROXY_PASSWORD)</password>
<host>$(inputs.params.PROXY_HOST)</host>
<port>$(inputs.params.PROXY_PORT)</port>
<nonProxyHosts>$(inputs.params.NON_PROXY_HOST)</nonProxyHosts>
</proxy>
</proxies>
</settings>
EOF
Expand Down
104 changes: 69 additions & 35 deletions maven/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,82 @@ metadata:
spec:
inputs:
params:
- name: GOALS
description: The Maven goals to run
type: array
default:
- "package"
- name: MAVEN_MIRROR_URL
description: The Maven bucketrepo- mirror
type: string
default: ""
- name: GOALS
description: The Maven goals to run
type: array
default:
- "package"
- name: MAVEN_MIRROR_URL
description: The Maven bucketrepo- mirror
type: string
default: ""
- name: PROXY_USER
description: The username for the proxy server
type: string
default: "testuser"
- name: PROXY_PASSWORD
description: The password for the proxy server
type: string
default: "testpassword"
- name: PROXY_PORT
description: Port number for the proxy server
type: string
default: "80"
- name: PROXY_HOST
description: Proxy server Host
type: string
default: ""
- name: NON_PROXY_HOST
description: Non proxy server host
type: string
default: ""
- name: PROXY_PROTOCOL
description: Protocol for the proxy ie http or https
type: string
default: "http"
resources:
- name: source
targetPath: /
type: git
- name: source
targetPath: /
type: git
steps:
- name: mvn-settings
image: registry.access.redhat.com/ubi8/ubi-minimal:latest
workingDir: /.m2
command:
- '/bin/bash'
- '-c'
args:
- |-
[[ -f /.m2/settings.xml ]] && \
echo 'using existing /.m2/settings.xml' && \
cat /.m2/settings.xml && exit 0
script: |
#!/usr/bin/env bash
[[ -f /.m2/settings.xml ]] && \
echo 'using existing /.m2/settings.xml' && \
cat /.m2/settings.xml && exit 0
[[ -n '$(inputs.params.MAVEN_MIRROR_URL)' ]] && \
cat > /.m2/settings.xml <<EOF
<settings>
<mirrors>
<mirror>
<id>mirror.default</id>
<name>mirror.default</name>
<url>$(inputs.params.MAVEN_MIRROR_URL)</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</settings>
EOF
[[ -n '$(inputs.params.MAVEN_MIRROR_URL)' ]] && \
cat > /.m2/settings.xml <<EOF
<settings>
<mirrors>
<mirror>
<id>mirror.default</id>
<name>mirror.default</name>
<url>$(inputs.params.MAVEN_MIRROR_URL)</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<proxies>
<proxy>
<id>proxy.default</id>
<active>true</active>
<protocol>$(inputs.params.PROXY_PROTOCOL)</protocol>
<username>$(inputs.params.PROXY_USER)</username>
<password>$(inputs.params.PROXY_PASSWORD)</password>
<host>$(inputs.params.PROXY_HOST)</host>
<port>$(inputs.params.PROXY_PORT)</port>
<nonProxyHosts>$(inputs.params.NON_PROXY_HOST)</nonProxyHosts>
</proxy>
</proxies>
</settings>
EOF
[[ -f /.m2/settings.xml ]] && cat /.m2/settings.xml
[[ -f /.m2/settings.xml ]] || echo skipping settings
[[ -f /.m2/settings.xml ]] && cat /.m2/settings.xml
[[ -f /.m2/settings.xml ]] || echo skipping settings
volumeMounts:
- name: m2-repository
mountPath: /.m2
Expand Down

0 comments on commit 86f50bc

Please sign in to comment.