diff --git a/API.md b/API.md index 7767c2e..6e94a25 100644 --- a/API.md +++ b/API.md @@ -3109,7 +3109,7 @@ new TaskBuilder(scope: Construct, id: string) | withDescription | Sets the `description` of the `Task` being built. | | withLabel | Adds a label to the `Task` with the provided label key and value. | | withName | Sets the name of the `Task` being built. | -| withResult | Allows you to add an result to the Task. | +| withResult | Allows you to add a result to the Task. | | withStep | Adds the given `step` (`TaskStepBuilder`) to the `Task`. | | withStringParam | Adds a parameter of type string to the `Task`. | | withWorkspace | Adds the specified workspace to the `Task`. | @@ -3206,7 +3206,7 @@ Sets the name of the `Task` being built. public withResult(name: string, description: string): TaskBuilder ``` -Allows you to add an result to the Task. +Allows you to add a result to the Task. > [https://tekton.dev/docs/pipelines/tasks/#emitting-results](https://tekton.dev/docs/pipelines/tasks/#emitting-results) @@ -3410,6 +3410,7 @@ new TaskStepBuilder() | fromScriptData | If supplied, uses the provided script data as-is for the script value. | | fromScriptObject | If supplied, uses the cdk8s `ApiObject` supplied as the body of the `script` for the `Task`. | | fromScriptUrl | If supplied, uses the content found at the given URL for the `script` value of the step. | +| fromScriptUrlToResults | If supplied, uses the content found at the given URL for the `script` value of the step and writes its output to the `results`. | | withArgs | The args to use with the `command`. | | withCommand | The name of the command to use when running the `Step` of the `Task`. | | withEnv | *No description.* | @@ -3483,6 +3484,30 @@ If you supply this, do not supply a value for `fromScriptObject`. --- +##### `fromScriptUrlToResults` + +```typescript +public fromScriptUrlToResults(url: string, resultsName: string): TaskStepBuilder +``` + +If supplied, uses the content found at the given URL for the `script` value of the step and writes its output to the `results`. + +Use this as an +alternative to "heredoc", which is embedding hard-coded shell or other +scripts in the step. + +###### `url`Required + +- *Type:* string + +--- + +###### `resultsName`Required + +- *Type:* string + +--- + ##### `withArgs` ```typescript diff --git a/test/__snapshots__/taskbuilder.test.ts.snap b/test/__snapshots__/taskbuilder.test.ts.snap index be79ec6..dd7d060 100644 --- a/test/__snapshots__/taskbuilder.test.ts.snap +++ b/test/__snapshots__/taskbuilder.test.ts.snap @@ -283,7 +283,7 @@ exports[`TaskBuilderTest TestIBMCloudSecretsManagerGet 1`] = ` "env": undefined, "image": "quay.io/openshift/origin-cli:4.7", "name": "retrieve-key", - "script": "#!/usr/bin/env bash\\nset -x\\n\\n# Retrieves the IBM Cloud API Key configured in a \`deployer\` cluster\\n\\nexport IBMCLOUD_API_KEY=$(oc get secret ibm-secret -n kube-system -o jsonpath='{.data.apiKey}' | base64 -d)\\nexport AUTH_RESPONSE_JSON=$(curl -s -X POST \\\\n "https://iam.cloud.ibm.com/identity/token" \\\\n --header 'Content-Type: application/x-www-form-urlencoded' \\\\n --header 'Accept: application/json' \\\\n --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey' \\\\n --data-urlencode "apikey=\${IBMCLOUD_API_KEY}")\\nexport ACCESS_TOKEN=$(echo $AUTH_RESPONSE_JSON | grep -o '"access_token":"[^"]*' | grep -o '[^"]*$')\\nexport SECRET_JSON=$(curl -s -X GET --location --header "Authorization: Bearer \${ACCESS_TOKEN}" --header "Accept: application/json" "$(params.SECRETS_MANAGER_ENDPOINT_URL)/api/v2/secrets/$(params.KEY_ID)")\\nexport SECRET=$(echo $SECRET_JSON | grep -o '"payload":"[^"]*' | grep -o '[^"]*$')\\nprintf "\${SECRET}"|tee $(results.secret-value.path)", + "script": "#!/usr/bin/env bash\\nset -x\\n\\n# Retrieves the IBM Cloud API Key configured in a \`deployer\` cluster\\n\\nexport IBMCLOUD_API_KEY=$(oc get secret ibm-secret -n kube-system -o jsonpath='{.data.apiKey}' | base64 -d)\\nexport AUTH_RESPONSE_JSON=$(curl -s -X POST \\\\n "https://iam.cloud.ibm.com/identity/token" \\\\n --header 'Content-Type: application/x-www-form-urlencoded' \\\\n --header 'Accept: application/json' \\\\n --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey' \\\\n --data-urlencode "apikey=\${IBMCLOUD_API_KEY}")\\nexport ACCESS_TOKEN=$(echo $AUTH_RESPONSE_JSON | grep -o '"access_token":"[^"]*' | grep -o '[^"]*$')\\nexport SECRET_JSON=$(curl -s -X GET --location --header "Authorization: Bearer \${ACCESS_TOKEN}" --header "Accept: application/json" "$(params.SECRETS_MANAGER_ENDPOINT_URL)/api/v2/secrets/$(params.KEY_ID)")\\nexport SECRET=$(echo $SECRET_JSON | grep -o '"payload":"[^"]*' | grep -o '[^"]*$')\\nprintf "\${SECRET}"\\n|tee $(results.secret-value.path)", "workingDir": undefined, }, ],