|
| 1 | +name: End to end test of the 'http' resource kind |
| 2 | +pipelineid: "e2e/http" |
| 3 | + |
| 4 | +# Sources of type http returns either the body or a header |
| 5 | +sources: |
| 6 | + # Returns the content of the 'maven-metadata.xml' file content as source (multi-line, direct HTTP/200) |
| 7 | + getJenkinsWarArtifactMetadatas: |
| 8 | + kind: http |
| 9 | + spec: |
| 10 | + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml |
| 11 | + # Returns the content of the 'checksums.txt' file content as source (multi-line, following redirections HTTP/3xx) |
| 12 | + getUpdatecli0.65.1Checksums: |
| 13 | + kind: http |
| 14 | + spec: |
| 15 | + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/checksums.txt # HTTP/302 (GitHub redirection to raw.githubusercontent.com) |
| 16 | + ## Empty Source due to HTTP/3xx not followed (e.g. empty body) |
| 17 | + getUpdatecli0.65.1ChecksumsNoFollow: |
| 18 | + kind: http |
| 19 | + spec: |
| 20 | + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/checksums.txt # HTTP/302 (GitHub redirection to raw.githubusercontent.com) |
| 21 | + request: |
| 22 | + nofollowredirects: true # Default is false |
| 23 | + # Returns the content of the Header 'Location' (e.g. the target of the HTTP redirect) |
| 24 | + getRedirectLocationForUpdatecliLinuxAmd64Archive: |
| 25 | + kind: http |
| 26 | + spec: |
| 27 | + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/updatecli_Linux_arm64.tar.gz |
| 28 | + returnresponseheader: Location |
| 29 | + # Returns the content of the 'maven-metadata.xml' file from the private URL (custom headers for the request) |
| 30 | + getWithCustomRequest: |
| 31 | + kind: http |
| 32 | + spec: |
| 33 | + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml |
| 34 | + request: |
| 35 | + headers: |
| 36 | + Authorization: 'Bearer Token' |
| 37 | + Accept: 'application/xml' |
| 38 | + verb: GET |
| 39 | + ## Source fails with an error: the URL returns HTTP/404 (same for server-side errors such as HTTP/5xx) |
| 40 | + # failOnHttpError: |
| 41 | + # kind: http |
| 42 | + # spec: |
| 43 | + # url: https://google.com/do-not-exist |
| 44 | + |
| 45 | + |
| 46 | +conditions: |
| 47 | + # Returns 'true' if the specified URL returns HTTP/1xx, HTTP/2xx or HTTP/3xx |
| 48 | + checkForURL: |
| 49 | + kind: http |
| 50 | + sourceid: getJenkinsWarArtifactMetadatas |
| 51 | + spec: |
| 52 | + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml |
| 53 | + ## Conditions returns 'false' as the URL returns HTTP/404 |
| 54 | + ## If there is an HTTP/500 (server side error) then the conditions fails with an ERROR (different than returning false which "skips" the pipeline) |
| 55 | + # checkForNonExistingUrl: |
| 56 | + # kind: http |
| 57 | + # sourceid: getJenkinsWarArtifactMetadatas |
| 58 | + # spec: |
| 59 | + # url: https://google.com/do-not-exist |
| 60 | + # Returns 'true' if the specified URL returns HTTP/1xx, HTTP/2xx or HTTP/3xx to the custom request (custom verb and headers) |
| 61 | + checkWithCustomRequest: |
| 62 | + kind: http |
| 63 | + sourceid: getJenkinsWarArtifactMetadatas |
| 64 | + spec: |
| 65 | + url: https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml |
| 66 | + request: |
| 67 | + headers: |
| 68 | + Authorization: 'Bearer Token' |
| 69 | + Accept: 'application/xml' |
| 70 | + verb: HEAD |
| 71 | + # Returns 'true' if the response code is HTTP/302 and has header "Content-Type" set to "application/xhtml" |
| 72 | + getUpdatecli0.65.1Checksums: |
| 73 | + kind: http |
| 74 | + sourceid: getJenkinsWarArtifactMetadatas |
| 75 | + spec: |
| 76 | + url: https://github.com/updatecli/updatecli/releases/download/v0.65.1/checksums.txt # HTTP/302 (GitHub redirection to raw.githubusercontent.com) |
| 77 | + responseasserts: |
| 78 | + statuscode: 302 |
| 79 | + headers: |
| 80 | + Content-Type: "text/html; charset=utf-8" |
| 81 | + |
0 commit comments