Docker Image jnlp-agent-python3

Hello Community,

I am working on a jenkins agent jnlp-agent-python3 but when I run the pipeline using this agent the pipeline fails as I think there is no git installed in the agent. Attaching the error screenshot here.

Does the recent image has git installed in it?
Or are there any image for Jenkins-agent can be used which has python-git?

Hello @Monit-dev and welcome to this community :wave:

I was about to say

This is an unmaintained image, forget about it

but I would have been wrong, as the last image got pushed 9 minutes ago.

I tried it, and there is no git available, you’re right:

docker run -it jenkins/jnlp-agent-python3 sh
which git
find / -name git

I would have liked to make tests with previous versions of the image, but I can’t seem to find any…
There is just the latest image in the repo.

The source code tells us it is based on the jenkins/inbound-agent:alpine image without adding directly git.
The source code of the inbound-agent:alpine image tells us it is based on jenkins/agent:3107.v665000b_51092-15-alpine-jdk17 without adding directly git.
The source code of the docker-agent adds the git package.

RUN apk add --no-cache \
      curl \
      bash \
      git \
      git-lfs \
      musl-locales \
      openssh-client \
      openssl \
      procps \
      tzdata \
      tzdata-utils \
    && rm -rf /tmp/*.apk /tmp/gcc /tmp/gcc-libs.tar* /tmp/libz /tmp/libz.tar.xz /var/cache/apk/*

The jenkins/agent:3107.v665000b_51092-15-alpine-jdk17 image finds git:

 docker run -it jenkins/agent:3107.v665000b_51092-15-alpine-jdk17 sh
Unable to find image 'jenkins/agent:3107.v665000b_51092-15-alpine-jdk17' locally
3107.v665000b_51092-15-alpine-jdk17: Pulling from jenkins/agent
8a49fdb3b6a5: Already exists
4bbec3de7f42: Pull complete
b2bae765b575: Pull complete
ead60d59a21a: Pull complete
fe69a7752636: Pull complete
39cdb922c757: Pull complete
ced24a0d93d2: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:8d53728d98f2bac12f83f9792e8ca5015d1bbcecb32e69622753db73aae721ac
Status: Downloaded newer image for jenkins/agent:3107.v665000b_51092-15-alpine-jdk17
~ $ git
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--config-env=<name>=<envvar>] <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect    Use binary search to find the commit that introduced a bug
   diff      Show changes between commits, commit and working tree, etc
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

grow, mark and tweak your common history
   branch    List, create, or delete branches
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
~ $

The jenkins/inbound-agent:alpine image also finds git:

docker run -it jenkins/inbound-agent:alpine sh
Unable to find image 'jenkins/inbound-agent:alpine' locally
alpine: Pulling from jenkins/inbound-agent
8a49fdb3b6a5: Already exists
4bbec3de7f42: Already exists
b2bae765b575: Already exists
ead60d59a21a: Already exists
fe69a7752636: Already exists
09167d178b28: Pull complete
ced24a0d93d2: Pull complete
4f4fb700ef54: Pull complete
4e02768bd69a: Pull complete
a49126b5dbc2: Pull complete
Digest: sha256:956a71934e9f1d85a9d196c6d626f57acde44de10a1c80ab174f4dbcb2edeaa9
Status: Downloaded newer image for jenkins/inbound-agent:alpine
~ $ git
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--config-env=<name>=<envvar>] <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect    Use binary search to find the commit that introduced a bug
   diff      Show changes between commits, commit and working tree, etc
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

grow, mark and tweak your common history
   branch    List, create, or delete branches
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
~ $

Now, I’m puzzled… :thinking:

Thanks to the guidance of @dduportal, I know understand why you “lost” git.
The Dockerfile for the image you’re using is taking some parts of the official python image, and parts of the official inbound-agent image, but does not bother to include all packages from the inbound-agent image, or from the python image.
You should build your own image based on the inbound-agent image.

1 Like