I assume that the temp directory and such has something to do with Jenkin's 
way of making the script pauseable and restartable (just a guess).  

Either way, it is safer to provide the path to your script to execute. Just 
reference it with $WORKSPACE/deploy-script.sh. 

I'd be interested in hearing the details about how and why that temp 
directory is created if anyone knows. 

On Tuesday, October 17, 2017 at 11:03:56 AM UTC-6, Thor Waway wrote:
>
> Hello, 
>
> This is a bit of newbie question so I apologize in advance. 
>
>
>    - I have 2 nodes currently set up; a MASTER and a WORKER node.  
>
>
>
>    - One of the steps in my declarative pipeline points to 
>    deploy-script.sh. The contents of  deploy-script.sh: 
>    - #!/bin/sh 
>    
>    whoami
>    
>    
> While ssh'ed into WORKER node, from the workspace directory, I am able to 
> run
>
>    - sh ./deploy-script.sh
>    
> and get the username of the current user (meaning no permission denied 
> errors). Yet when this same command runs (in the content of steps defined 
> in a JenkinsFile) I get a *Permission Denied* error
>
>
> *Two things I noticed while trying to work through this issue*
> 1). When I call sh and pass it a command directly, for example: 
>
> stage("Trial){
>   steps{
>    sh "whoami"
>    sh  "pwd"
>   }
> }
>
>
>
>         I get: 
>
> [feature-jenkinsfile] Running shell script
> + whoami
> worker-agent
> [Pipeline] sh
> [feature-jenkinsfile] Running shell script
> + pwd
> /home/worker-agent/jenkins/workspace/feature-jenkinsfile
>
>
>
>
> 2). Yet when I call 'sh' and pass it a path to a file to run, as I do 
> here: 
>
> stage('Trial2'){
>   steps{
>    sh "pwd"
>    sh "./deploy-script.sh"
>   }
> }
>
>
>           It appears that Jenkins creates a new temporary folder from 
> within which it runs the script as can be seen by here: 
>
> [Pipeline] sh
> [feature-jenkinsfile] Running shell script
> + pwd
> /home/worker-agent/jenkins/workspace/feature-jenkinsfile
> [Pipeline] sh
> [feature-jenkinsfile] Running shell script
> + ./deploy-staging.sh
> /home/worker-agent/jenkins/workspace/feature-jenkinsfile@tmp/durable-7e1f206b/script.sh:
>  2: 
> /home/worker-agent/jenkins/workspace/feature-jenkinsfile@tmp/durable-7e1f206b/script.sh:
>  ./deploy-staging.sh: Permission denied
>
>
> When I run `ls -l` from 
>
> What am I missing? What am I failing to take into account?  Would appreciate 
> any feedback/explanations. Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8e16be72-6522-492b-abc6-f72e67651ce7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to