我正在尝试在Docker的Jenkins阶段构建Snap软件包(它只运行构建脚本),但最终我得到了这一点:
Sorry, Snapcraft ran into an error when trying to running through its
lifecycle that generated the following traceback:
Traceback (most recent call last):
File "/usr/bin/snapcraft", line 9, in <module>
load_entry_point('snapcraft==2.42.1', 'console_scripts', 'snapcraft')()
File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1037, in invoke
return Command.invoke(self, ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3/dist-packages/snapcraft/cli/_runner.py", line 79, in run
ctx.forward(lifecyclecli.commands['snap'])
File "/usr/lib/python3/dist-packages/click/core.py", line 552, in forward
return self.invoke(cmd, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 135, in snap
project_options, directory=directory, output=output)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_packer.py", line 46, in snap
execute('prime', project_options)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 60, in execute
config = project_loader.load_config(project_options)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/__init__.py", line 31, in load_config
return Config(project_options)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_config.py", line 215, in __init__
snapcraft_yaml = self._process_remote_parts(snapcraft_yaml)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_config.py", line 355, in _process_remote_parts
properties = self._remote_parts.get_part(after_part)
File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_config.py", line 198, in _remote_parts
self._remote_parts_attr = remote_parts.get_remote_parts()
File "/usr/lib/python3/dist-packages/snapcraft/internal/remote_parts.py", line 83, in get_remote_parts
return _RemoteParts()
File "/usr/lib/python3/dist-packages/snapcraft/internal/remote_parts.py", line 140, in __init__
super().__init__()
File "/usr/lib/python3/dist-packages/snapcraft/internal/remote_parts.py", line 94, in __init__
os.makedirs(self.parts_dir, exist_ok=True)
File "/usr/lib/python3.5/os.py", line 231, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.5/os.py", line 231, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.5/os.py", line 231, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.local'
所以:PermissionError: [Errno 13] Permission denied: '/.local'
现在我不明白的是,如果我手动运行构建脚本,它将起作用:
CMD="export LANG=en_US.UTF-8 && \
export LC_ALL=en_US.UTF-8 && \
cd /heimer/packaging/snap && \
snapcraft"
docker run --privileged -t -v $(pwd):/heimer juzzlin/qt5:16.04 bash -c "${CMD}"
这是我在Jenkinsfile中运行它的方式:
stage('Snap package / Ubuntu 16.04') {
agent {
docker {
image 'juzzlin/qt5:16.04'
args '--privileged -t -v $WORKSPACE:/heimer'
}
}
steps {
sh "./scripts/buildSnap.sh"
}
post {
always {
archiveArtifacts artifacts: 'packaging/snap/*.snap', fingerprint: true
}
}
}
有什么区别?为什么Jenkins运行它会失败?