I have a jenkins script that looks like this:
pipeline {
agent {
label 'machine'
}
stages {
stage('GC Open Build') {
steps {
sh '''
docker run -i --rm \
-u $(id -u):$(id -g) \
-e USER_NAME=$(id -un) \
-e GROUP_NAME=$(id -gn) \
-e HOME \
-v $HOME:$HOME \
-v /PROJ:/PROJ:shared \
-v /srv:/srv \
-w $PWD \
i-st-pd-docker-vxxxxxx
bash | hostname
'''
}
}
}
}
It executes successfully, but the hostname it displays is not the docker container, but the machine on which it runs.
If I try with '-t' in the docker run command, then I get "the input device is not a tty":
pipeline {
agent {
label 'machine'
}
stages {
stage('GC Open Build') {
steps {
sh '''
docker run -it --rm \
-u $(id -u):$(id -g) \
-e USER_NAME=$(id -un) \
-e GROUP_NAME=$(id -gn) \
-e HOME \
-v $HOME:$HOME \
-v /PROJ:/PROJ:shared \
-v /srv:/srv \
-w $PWD \
i-st-pd-docker-v.xxxx
bash | hostname
'''
}
}
}
}
the input device is not a TTY ERROR: script returned exit code 1
Any suggestions to be able to run a set of commands (other than "hostname" from inside the docker container?
Thank you!