Netrc missing in just-built container

Hi – I’m trying to create and run an image in a pipeline. When run, that image’s needs to git fetch to update some references. Specifically, the pipeline looks like:

- name: build image

- name: run image just built

Unexpectedly, the entrypoint is failing with the classic terminal prompt disabled etc and ls -la ~ shows no .netrc (although previous steps show it present).

Is it expected that the latter step would not have the netrc mounted into it? Is there a way around it? Thanks.

The netrc is not automatically created for all repositories or all types of pipeline steps. The netrc is only created if the repository is private and the step is a commands step, where Drone overrides the default entrypoint to execute your shell commands. The netrc is not automatically created for steps that use the default image entrypoint (plugins, services, etc).

You may therefore need to generate the netrc from the environment, similar to what we are doing in many of our plugins [1] that rely on this file:

if [ ! -z "${DRONE_NETRC_FILE}" ]; then
	echo $DRONE_NETRC_FILE > $HOME/.netrc
	chmod 600 $HOME/.netrc

[1] drone-git/clone at master · drone/drone-git · GitHub

This was exactly it – thanks for your help.

  if [[ -n "${DRONE_NETRC_MACHINE}" ]]; then
    cat <<EOF >/root/.netrc