jenkinsci / jenkinsci/ssh-agent-plugin

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

Open
#255 0 comments 0 reactions 0 assignees View on GitHub
component:ssh-agent-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
63
Forks
81
Avg merge
5h 36m
Merged PRs (30d)
9

Description

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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.