question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quotes Not Supported For Secrets or Build-Args

See original GitHub issue

Behavior

When you provide a secret value with quotes, like a JSON. The action fails with:

> Run docker/build-push-action@v2
📣 Buildx version: 0.4.2
Error: Invalid Opening Quote: a quote is found inside a field at line 1

Escaping the quotes or using single quotes doesn’t help either, tried:

{"host":"host","user":"user","pass":"pass"}
'{"host":"host","user":"user","pass":"pass"}'
{'host':'host','user':'user','pass':'pass'}
"{'host':'host','user':'user','pass':'pass'}"
{\"host\":\"host\",\"user\":\"user\",\"pass\":\"pass\"}
'{\"host\":\"host\",\"user\":\"user\",\"pass\":\"pass\"}'

Steps to reproduce this issue

  1. Set a secret with quotes. E.g: SERVER with value {"host":"host","user":"user","pass":"pass"}
  2. Use that secret for either the secret or build-args:
-
  	name: Build and Push image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: ${{ env.IMAGE_NAME }}:latest
          file: ./Dockerfile
          build-args: |
            SERVER=${{ secrets.SERVER }}
          secrets: |
            SERVER=${{ secrets.SERVER }}
  1. Run the workflow

Expected behaviour

Expected to set the secret value to either the build-args or secrets so it can be used at build.

Actual behaviour

The parsing of the values return Error: Invalid Opening Quote: a quote is found inside a field at line 1

Configuration

  • Repository URL (if public): Not public, but you can use the info provided above to reproduce the error.
  • Build URL (if public): Not public, but you can use the info provided above to reproduce the error.

Logs

Download the log file of your build and attach it to this issue.

Can’t do this, the logs are not public.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
malkam03commented, Dec 3, 2020

@malkam03 As explained in the README, quote signs need to be doubled for escaping.

Ah, sorry beginners error. Thank you for your prompt response!

0reactions
malkam03commented, Dec 3, 2020

Yes, that works! Thank you very much! I created a PR if it works for someone else https://github.com/docker/build-push-action/pull/246.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is ARG in a DOCKERFILE not recommended for passing ...
The secret command only helps swarm users is not a more general ... Even if the build-args are saved somewhere, they become useless...
Read more >
build-arg not support multiline variable · Issue #374 - GitHub
Troubleshooting I need to save a multiline variable to a file. But the result is a file with only one line. secrets.
Read more >
Understanding Docker Build Args, Environment Variables and ...
An overview of ways to set and use variables when building images, starting containers and using docker-compose.
Read more >
Compose file version 3 reference - Docker Documentation
This table shows which Compose file versions support specific Docker releases. ... be enclosed in quotes, so that the parser interprets them as...
Read more >
Build Arguments - CloudBees Documentation
This article is about using Docker build arguments with CloudBees CodeShip Pro. ... Because of this, CodeShip supports encrypted build arguments.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found