docker-publish failed: python3: command not found
When publishing the image in a docker registry, a "skopeo" image is used and calling merge_json function in "gitlab-ci-docker.yml " leading to :
Gitlab job log
$ ( # collapsed multi-line command
$ # BEGSCRIPT # collapsed multi-line command
[INFO] Custom CA certificates imported in /etc/ssl/certs/ca-certificates.crt
/scripts-516489-270967115/step_script: line 534: python3: command not found
The code of the function is
function merge_json() {
python3 -c "import json,sys
def merge(a,b):
for key in b:
if key in a and isinstance(a[key],dict) and isinstance(b[key],dict): a[key]=merge(a[key],b[key])
else: a[key]=b[key]
return a
def mergef(*files):
res={}
for f in files:
with open(f,'r') as rd: res=merge(res,json.load(rd))
return res
print(json.dumps(mergef(*sys.argv[1:])))" "$@"
}
A python code checker is reporting:
Traceback (most recent call last): ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error on line 2: python3 -c "import json,sys ^ SyntaxError: unterminated string literal (detected at line 2)
Could it be a simply a problem with bad indentation or line continuation interpretation?
For better lisibility, of the function, can we try something like:
python3 -c "
import json, sys
def merge(a, b):
for key in b:
if key in a and isinstance(a[key], dict) and isinstance(b[key], dict):
a[key] = merge(a[key], b[key])
else:
a[key] = b[key]
return a
def mergef(*files):
res = {}
for f in files:
with open(f, 'r') as rd:
res = merge(res, json.load(rd))
return res
print(json.dumps(mergef(*sys.argv[1:])))
" "$@"
Edited by Didier Oguer