When a BuildConfig
is created, {product-title} can automatically populate its
source clone secret reference. This behavior allows the resulting Builds
to
automatically use the credentials stored in the referenced Secret
to
authenticate to a remote Git repository, without requiring further
configuration.
To use this functionality, a Secret
containing the Git repository credentials
must exist in the namespace in which the BuildConfig
is later created.
This Secret
must additionally include one or more annotations prefixed with
build.openshift.io/source-secret-match-uri-
. The value of each of these
annotations is a URI pattern, defined as follows. When a BuildConfig
is created
without a source clone secret reference and its Git source URI matches a URI
pattern in a Secret
annotation, {product-title} will automatically insert a
reference to that Secret
in the BuildConfig
.
A URI pattern must consist of:
-
a valid scheme (
*://
,git://
,http://
,https://
orssh://
). -
a host (
*
or a valid hostname or IP address optionally preceded by*.
). -
a path (
/*
or/
followed by any characters optionally including*
characters).
In all of the above, a *
character is interpreted as a wildcard.
Important
|
URI patterns must match Git source URIs which are conformant to RFC3986. Do not include a username (or password) component in a URI pattern. For example, if you use
$ oc annotate secret mysecret \ 'build.openshift.io/source-secret-match-uri-1=ssh://bitbucket.atlassian.com:7999/*' |
If multiple Secrets
match the Git URI of a particular BuildConfig
,
{product-title} will select the secret with the longest match. This allows for
basic overriding, as in the following example.
The following fragment shows two partial source clone secrets, the first
matching any server in the domain mycorp.com
accessed by HTTPS, and the second
overriding access to servers mydev1.mycorp.com
and mydev2.mycorp.com
:
kind: Secret
apiVersion: v1
metadata:
name: matches-all-corporate-servers-https-only
annotations:
build.openshift.io/source-secret-match-uri-1: https://*.mycorp.com/*
data:
...
kind: Secret
apiVersion: v1
metadata:
name: override-for-my-dev-servers-https-only
annotations:
build.openshift.io/source-secret-match-uri-1: https://mydev1.mycorp.com/*
build.openshift.io/source-secret-match-uri-2: https://mydev2.mycorp.com/*
data:
...
-
Add a
build.openshift.io/source-secret-match-uri-
annotation to a pre-existing secret using:
$ oc annotate secret mysecret \ 'build.openshift.io/source-secret-match-uri-1=https://*.mycorp.com/*'