diff --git a/assets/code_example/docs/plugins/resources/http/updatecli.d/default.yaml b/assets/code_example/docs/plugins/resources/http/updatecli.d/default.yaml new file mode 100644 index 000000000..16d38dad7 --- /dev/null +++ b/assets/code_example/docs/plugins/resources/http/updatecli.d/default.yaml @@ -0,0 +1,81 @@ +name: End to end test of the 'http' resource kind +pipelineid: "e2e/http" + +# Sources of type http returns either the body or a header +sources: + # Returns the content of the 'maven-metadata.xml' file content as source (multi-line, direct HTTP/200) + getJenkinsWarArtifactMetadatas: + kind: http + spec: + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml + # Returns the content of the 'checksums.txt' file content as source (multi-line, following redirections HTTP/3xx) + getUpdatecli0.65.1Checksums: + kind: http + spec: + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/checksums.txt # HTTP/302 (GitHub redirection to raw.githubusercontent.com) + ## Empty Source due to HTTP/3xx not followed (e.g. empty body) + getUpdatecli0.65.1ChecksumsNoFollow: + kind: http + spec: + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/checksums.txt # HTTP/302 (GitHub redirection to raw.githubusercontent.com) + request: + nofollowredirects: true # Default is false + # Returns the content of the Header 'Location' (e.g. the target of the HTTP redirect) + getRedirectLocationForUpdatecliLinuxAmd64Archive: + kind: http + spec: + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/updatecli_Linux_arm64.tar.gz + returnresponseheader: Location + # Returns the content of the 'maven-metadata.xml' file from the private URL (custom headers for the request) + getWithCustomRequest: + kind: http + spec: + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml + request: + headers: + Authorization: 'Bearer Token' + Accept: 'application/xml' + verb: GET + ## Source fails with an error: the URL returns HTTP/404 (same for server-side errors such as HTTP/5xx) + # failOnHttpError: + # kind: http + # spec: + # url: https://google.com/do-not-exist + + +conditions: + # Returns 'true' if the specified URL returns HTTP/1xx, HTTP/2xx or HTTP/3xx + checkForURL: + kind: http + sourceid: getJenkinsWarArtifactMetadatas + spec: + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml + ## Conditions returns 'false' as the URL returns HTTP/404 + ## If there is an HTTP/500 (server side error) then the conditions fails with an ERROR (different than returning false which "skips" the pipeline) + # checkForNonExistingUrl: + # kind: http + # sourceid: getJenkinsWarArtifactMetadatas + # spec: + # url: https://google.com/do-not-exist + # Returns 'true' if the specified URL returns HTTP/1xx, HTTP/2xx or HTTP/3xx to the custom request (custom verb and headers) + checkWithCustomRequest: + kind: http + sourceid: getJenkinsWarArtifactMetadatas + spec: + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml + request: + headers: + Authorization: 'Bearer Token' + Accept: 'application/xml' + verb: HEAD + # Returns 'true' if the response code is HTTP/302 and has header "Content-Type" set to "application/xhtml" + getUpdatecli0.65.1Checksums: + kind: http + sourceid: getJenkinsWarArtifactMetadatas + spec: + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/checksums.txt # HTTP/302 (GitHub redirection to raw.githubusercontent.com) + responseasserts: + statuscode: 302 + headers: + Content-Type: "text/html; charset=utf-8" + diff --git a/assets/code_example/docs/plugins/resources/http/updatecli.d/json.yaml b/assets/code_example/docs/plugins/resources/http/updatecli.d/json.yaml new file mode 100644 index 000000000..c49953e50 --- /dev/null +++ b/assets/code_example/docs/plugins/resources/http/updatecli.d/json.yaml @@ -0,0 +1,38 @@ +name: Basic Json Example + +sources: + http: + name: Get value from json + kind: json + spec: + file: https://www.updatecli.io/schema/latest/config.json + key: $id + semverVersion: + kind: json + name: Get latest version + spec: + file: https://www.updatecli.io/changelogs/updatecli/_index.json + query: ".Changelogs.[*].Tag" + versionfilter: + kind: semver + pattern: "v0.92.0" + +conditions: + http: + name: Test value from json + kind: json + disablesourceinput: true + spec: + file: https://www.updatecli.io/schema/latest/config.json + key: $schema + value: http://json-schema.org/draft-04/schema + + http-query: + kind: json + name: Get latest version + disablesourceinput: true + spec: + file: https://www.updatecli.io/changelogs/updatecli/_index.json + key: ".Changelogs.(Tag=v0.92.0).PublishedAt" + value: "2025-01-12 08:14:30 +0000 UTC" + diff --git a/content/en/docs/plugins/resource/http.adoc b/content/en/docs/plugins/resource/http.adoc new file mode 100644 index 000000000..687fc7da6 --- /dev/null +++ b/content/en/docs/plugins/resource/http.adoc @@ -0,0 +1,62 @@ +--- +title: "HTTP" +description: "Run HTML request" +lead: "kind: http" +date: 2024-02-26T09:00:00+02:00 +draft: false +images: [] +menu: + docs: + parent: "plugin-resource" +toc: true +plugins: + - source + - condition + - target +--- +// +:toc: +// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key +:toclevels: 4 + +[cols="1^,1^,1^",options=header] +|=== +| source | condition | target +| ✔ | ✔ | ✔ +|=== + +== Description + +**source** + +The HTML "source" retrieves an information from a HTTP request. + +**condition** + +The HTML "condition" tests that an information exist in a HTTP response. + +**target** + +The HTML "target" updates a HTTP response. + +== Parameters + +{{< resourceparameters "sources" "http" >}} + +== Example + +[source,yaml] +---- +# updatecli.yaml +{{}} +---- + +== Important + +Most of the Updatecli plugins that manipulate files can usually specify the http scheme in the file path to retrieve the file from a remote location to be used in a source or a condition. But the HTTP plugin is designed to provide more flexibility when working with HTTP requests via additional settings like custom headers, or custom http verbs. Also worth mentioning the http plugin also works for targets. + +[source,yaml] +---- +# updatecli.yaml +{{}} +----