Shellscript touch command not working in jenkins pipeline

22 Views Asked by At

I'm having the below shell script which works fine (generates file with timestamp) when I execute it from linux. But it is not working when I execute it from a Jenkins pipeline.

echo "Generating file"
touch "genfile_$(date +"%Y_%m_%d_%I_%M_%p")"
echo "end of file..."

Pipeline script:

pipeline {
    agent any

    stages {
        stage('Hello') {
            steps {
                sh '/dir/Jenkins/genfile.sh'
            }
        }
    }
}

I only see echo commands output in Jenkins console ("Generating file" and "end of file"). But in the backend, touch command is not working though the script executed.

0

There are 0 best solutions below