I have this gitlab job: .build: stage: build image: name:…
- User
I have this gitlab job:
.build: stage: build image: name: gcr.io/kaniko-project/executor:v1.9.0-debug entrypoint: [ "" ] script: - | if [[ "{DOCKER_FILE%/*}" # get the dirname (path only) DFILE="{DOCKER_FILE##*/}" # get the basename (filename only) else DPATH="." DFILE="{DOCKER_FILE}" # If no path, DOCKER_FILE is just the filename fi - echo "DPATH: {DPATH}" # For debugging - echo "DFILE: {DFILE}" # For debugging - /kaniko/executor --context "{DFILE}" --destination "CI_COMMIT_TAG" --build-arg PIP_PIPE_INSTALL_TOKEN="{EXTRA_ARGS} - --cache=true - --cache-ttl=168h - --cache-repo=BUILD == "true" && {DOCKER_FILE}
build: extends: .build variables: DOCKER_FILE: Dockerfile IMAGE: $CI_REGISTRY_IMAGE EXTRA_ARGS: ""
I get this error: jobs:build:script config should be a string or a nested array of strings up to 10 levels deep
Assistant
The error you're encountering is because the script section in your GitLab CI job is not properly formatted. In GitLab CI, each script command should be a separate string in an array, or a single string with commands separated by newlines.
Here's the corrected version of your job:
.build: stage: build image: name: gcr.io/kaniko-project/executor:v1.9.0-debug entrypoint: [ "" ] script: - | if [[ "${DOCKER_FILE}" == */* ]]; then DPATH="${DOCKER_FILE%/*}" # get the dirname (path only) DFILE="${DOCKER_FILE##*/}" # get the basename (filename only) else DPATH="." DFILE="${DOCKER_FILE}" # If no path, DOCKER_FILE is just the filename fi echo "DPATH: ${DPATH}" # For debugging echo "DFILE: ${DFILE}" # For debugging /kaniko/executor --context "${DPATH}" --dockerfile "${DFILE}" --destination "$IMAGE:$CI_COMMIT_TAG" --build-arg PIP_PIPE_INSTALL_TOKEN="$PIP_PIPE_INSTALL_TOKEN" ${EXTRA_ARGS} - --cache=true - --cache-ttl=168h - --cache-repo=${CI_REGISTRY_IMAGE}/kaniko-cache rules: - if: '$BUILD == "true" && $CI_COMMIT_TAG' exists: - ${DOCKER_FILE} build: extends: .build variables: DOCKER_FILE: Dockerfile IMAGE: $CI_REGISTRY_IMAGE EXTRA_ARGS: ""Key changes:
- Combined all the script commands into a single multi-line string (using the
|character) - Removed the separate
- echocommands and included them in the same script block - The entire script is now one YAML string rather than multiple array items
This format is more appropriate for GitLab CI as it keeps related commands together in a single script block while maintaining proper YAML syntax.
- Combined all the script commands into a single multi-line string (using the
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.