Skip to content

[JENKINS-66285] Cant get content file through subshell syntax: $(command) in ssh-agent #255

Description

@jenkins-infra-bot

I build images usig Jenkinsfile with my versioning which store in txt files.

And I use ssh-agent in post-actions to remove temporary images.

So I use command set like this:

cd /home/jenkins/docker/basic_images
export REPO="$(cat ./repo.txt)"
export PHP_VERSION=$(cat ./php-fpm/phpVersion.txt)
export PHP_IMAGE_NAME=$(cat ./php-fpm/imageName.txt)
export PHP_IMAGE_VERSION="$(cat ./php-fpm/imageVersion.txt)"
export PHP_COMMON_IMAGE_NAME=$REPO/basic-php-$PHP_VERSION-$PHP_IMAGE_NAME
docker rmi $PHP_COMMON_IMAGE_NAME:$PHP_IMAGE_VERSION

And in Console Output I see that result:

cd /home/jenkins/docker/basic_images
export REPO=""
export PHP_VERSION=
export PHP_IMAGE_NAME=
export PHP_IMAGE_VERSION=""
export PHP_COMMON_IMAGE_NAME=/basic-php--
docker rmi :

I tried many other bash possibilities: single/double quotes, apostrophes, while-cycle; set etc. And always blocked to get data from file to set env.

Besides other operations, which "echo $PATH", "cat ./" finished successful.

So: maybe you offer me the way to solve my problem?
Thx!


Originally reported by denisg, imported from: Cant get content file through subshell syntax: $(command) in ssh-agent
  • status: Open
  • priority: Minor
  • component(s): ssh-agent-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20260604-211335
Raw content of original issue

I build images usig Jenkinsfile with my versioning which store in txt files.

And I use ssh-agent in post-actions to remove temporary images.

So I use command set like this:

cd /home/jenkins/docker/basic_images
export REPO="$(cat ./repo.txt)"
export PHP_VERSION=$(cat ./php-fpm/phpVersion.txt)
export PHP_IMAGE_NAME=$(cat ./php-fpm/imageName.txt)
export PHP_IMAGE_VERSION="$(cat ./php-fpm/imageVersion.txt)"
export PHP_COMMON_IMAGE_NAME=$REPO/basic-php-$PHP_VERSION-$PHP_IMAGE_NAME
docker rmi $PHP_COMMON_IMAGE_NAME:$PHP_IMAGE_VERSION

And in Console Output I see that result:

cd /home/jenkins/docker/basic_images
export REPO=""
export PHP_VERSION=
export PHP_IMAGE_NAME=
export PHP_IMAGE_VERSION=""
export PHP_COMMON_IMAGE_NAME=/basic-php--
docker rmi :

I tried many other bash possibilities: single/double quotes, apostrophes, while-cycle; set etc. And always blocked to get data from file to set env.

Besides other operations, which "echo $PATH", "cat ./<filename>" finished successful.

So: maybe you offer me the way to solve my problem? Thx!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions