Issue with pipeline

851 views
Skip to first unread message

Sharan Basappa

unread,
Feb 7, 2017, 1:15:06 PM2/7/17
to Jenkins Users
Hi All,

I am having some trouble executing basic shell commands (highlighted in red). I cant figure out the issue. Need some help. This is what I get:

Branch indexing

> git rev-parse --is-inside-work-tree # timeout=10

Setting origin to git@hd1:testing

> git config remote.origin.url git@hd1:testing # timeout=10

Fetching origin...

Fetching upstream changes from origin

> git --version # timeout=10

> git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*

Seen branch in repository origin/master

Seen branch in repository origin/test

Seen branch in repository origin/test1

Seen branch in repository origin/testx

Seen 4 remote branches

> git rev-parse --is-inside-work-tree # timeout=10

Fetching changes from the remote Git repository

> git config remote.origin.url git@hd1:testing # timeout=10

Fetching upstream changes from git@hd1:testing

> git --version # timeout=10

> git fetch --tags --progress git@hd1:testing +refs/heads/*:refs/remotes/origin/*

Checking out Revision eb966a50720c888113925000ad9179c79b1c187b (test1)

> git config core.sparsecheckout # timeout=10

> git checkout -f eb966a50720c888113925000ad9179c79b1c187b

> git rev-list eb966a50720c888113925000ad9179c79b1c187b # timeout=10

[Pipeline] stage (build)

Using the ‘stage’ step without a block argument is deprecated

Entering stage build

Proceeding

[Pipeline] node

Running on master in /var/lib/jenkins/workspace/an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA

[Pipeline] {

[Pipeline] sh

[an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA] Running shell script

+ pwd

/var/lib/jenkins/workspace/an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA

[Pipeline] sh

[an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA] Running shell script

+ cat simple.csh

cat: simple.csh: No such file or directory

[Pipeline] }

[Pipeline] // node

[Pipeline] End of Pipeline

ERROR: script returned exit code 1

Finished: FAILURE

 

Indra Gunawan (ingunawa)

unread,
Feb 7, 2017, 1:19:43 PM2/7/17
to jenkins...@googlegroups.com

Do you have the simple.csh file checked-in or not?

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/73d02186-75a9-4e8a-8787-5ca05cc38ba5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Karr

unread,
Feb 7, 2017, 3:39:54 PM2/7/17
to Jenkins Users

When I run into issues like this, I often will run "sh('pwd')" and "sh('ls')" in the script, to verify exactly where I think I am, and what else is in the directory. The output from those should help.
 

Sharan Basappa

unread,
Feb 7, 2017, 9:24:45 PM2/7/17
to Jenkins Users
If you see the sequence of commands, you will notice that I have used pwd.
Let me list files and see if I can find anything

Sharan Basappa

unread,
Feb 8, 2017, 5:21:09 AM2/8/17
to Jenkins Users
Some updates from the experiments I tried out. I directly logged into the Linux machine where Jenkins is installed.
I cd'ed into the workspace and listed the files. My scripts are not listed.
I also found additional directories with @scripts suffix to the directories.
There the files are listed. Please see the transcript below. I am lost now ...

[root@hd1 workspace]# ls an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA

[root@hd1 workspace]#


[root@hd1 workspace]# ls an_example_test1-24PKZ6E7JM3ZFPAWUPX5ZXTQQLVB7HDDUSAFFRMP6IX3XZERQFTA@script

avalon_asrts.sv  binding.sv  dir1  Jenkinsfile  Just_Checking  simple.csh  source.csh  tb_avalon_asrts.sv


[root@hd1 workspace]# ls an_example_testx-PIODN73ROEXZPUFF2FZCSVYPXYDLWSUW4QWZH4CJIGKQA2HJSI3A\@script/

avalon_asrts.sv  binding.sv  dir1  Jenkinsfile  Just_Checking  simple.csh  source.csh  tb_avalon_asrts.sv


[root@hd1 workspace]# ls an_example_test-JXUTXQYEXLBFTQ57MDSHQEWRX4WVYMTOO7GTJHX5PXY7SUM2PYKA\@script/

Jenkinsfile  Just_Checking  simple.csh  temp

Sharan Basappa

unread,
Feb 8, 2017, 9:17:54 PM2/8/17
to Jenkins Users
folks,

I was able to resolve this by using {workspace}@script to access the files in the workspace.
But I would like to understand the reason behind having files in {workspace}@script rather than {workspace} ...

Daniel Beck

unread,
Feb 9, 2017, 9:31:46 AM2/9/17
to jenkins...@googlegroups.com

> On 09.02.2017, at 03:17, Sharan Basappa <sharan....@gmail.com> wrote:
>
> But I would like to understand the reason behind having files in {workspace}@script rather than {workspace} ...

The Jenkinsfile is checked out to @script so it's not in the actual workspace (duh), and you can e.g. deleteDir() to remove leftovers from previous builds without getting into problems (imagine a cartoon character sawing off the branch on which it sits…).

Did you forget to `checkout scm` inside the node block?

jer...@bodycad.com

unread,
Feb 9, 2017, 11:19:40 AM2/9/17
to Jenkins Users
the {workspace}@script is done during the initial fetch for the Jenkinsfile. Normally the pipeline checkout config. This first checkout is not transfer to the real workspace when you start the script

  1. the jenkinsfile checkout inside {workspace}@script. I strongly suggest you get a small repos without the source code, else you will be checkouting twice the source.
  2. read the jenkins file pipeline script inside {workspace}@script
  3. change the directory to {workspace}
  4. start executing the jenkinsfile inside {workspace}
  5. you pipeline script should scm checkout the real source code repos to compile or do any other tasks
I for one would like to have an env variables to get that @script folder, since @script2+ is possible. I used some script helper to run the pipeline script which are found into the Jenkinsfile repos only. Right now I do 3 checkout to ensure proper execution (I avoid refereing to {workspace}@script at all). 1 for the initial jenkinsfile into the @script, 2 the jenkinsfile repos again for script helper into workspace which I can access and 3 the source code itself into workspace.

Sharan Basappa

unread,
Feb 10, 2017, 5:35:34 AM2/10/17
to Jenkins Users
Folks,

At this point, I am so confused.

My Jenkins file is kept at the root of Git directory. I am doing this in branches where I want to do Jenkins build.
I am using multibranch pipeline plug-in to define the build on Jenkins server.

As I am doing only mock set-up for now, the pipeline job is very simple and looks as follows. Can someone explain where I am going wrong?
The log below clearly reports that it is checking out test3 branch. So, I expect repository to be checked out correctly.

node {

stage 'build'

sh "pwd"

sh "ls ${workspace}@script"

sh "echo $PATH"

sh "cat  ${workspace}@script/simple.csh"

sh "csh  ${workspace}@script/simple.csh"

 

stage 'merge'

sh 'git stash'

sh 'git checkout master'

sh 'git merge test3'

sh 'git commit -am "Merged test3 branch to master"'

sh "git push origin master"

}


The script executes all the way till "git stash" and at this point, it reports error.
I have attached the entire log.

Branch indexing
> git rev-parse --is-inside-work-tree # timeout=10
Setting origin to git@hd1:testing
> git config remote.origin.url git@hd1:testing # timeout=10
Fetching origin...
Fetching upstream changes from origin
> git --version # timeout=10
> git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/master
Seen branch in repository origin/test
Seen branch in repository origin/test1
Seen branch in repository origin/test2
Seen branch in repository origin/test3
Seen branch in repository origin/test4

Seen branch in repository origin/testx
Seen 7 remote branches

> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@hd1:testing # timeout=10
Fetching upstream changes from git@hd1:testing
> git --version # timeout=10
> git fetch --tags --progress git@hd1:testing +refs/heads/*:refs/remotes/origin/*
Checking out Revision f5eabd27c25242cc35d0b597537c3a3bcec8f54f (test3)

> git config core.sparsecheckout # timeout=10
> git checkout -f f5eabd27c25242cc35d0b597537c3a3bcec8f54f
> git rev-list 18552ecf03f27679cb0d88f28c096d5c7ec33d99 # timeout=10
[Pipeline] node Running on master in /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A
[Pipeline] { [Pipeline] stage (build) Using the ‘stage’ step without a block argument is deprecated
Entering stage build
Proceeding
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ pwd
/var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ ls /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A@script

avalon_asrts.sv
binding.sv
dir1
Jenkinsfile
Just_Checking
simple.csh
source.csh
tb_avalon_asrts.sv
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ echo /sbin:/usr/sbin:/bin:/usr/bin
/sbin:/usr/sbin:/bin:/usr/bin
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ cat /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A@script/simple.csh
#!/bin/csh -f -e -x
echo "welcome to Jenkins from test2 branch"
\rm -f t
echo "junk" > t
exit 0
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ csh /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A@script/simple.csh
welcome to Jenkins from test2 branch
[Pipeline] stage (merge) Using the ‘stage’ step without a block argument is deprecated
Entering stage merge
Proceeding
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ git stash
fatal: Not a git repository (or any of the parent directories): .git
[Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 128
Finished: FAILURE

Sharan Basappa

unread,
Feb 10, 2017, 5:38:51 AM2/10/17
to Jenkins Users
Folks,

At this point, I am so confused.

My Jenkins file is kept at the root of Git directory. I am doing this in branches where I want to do Jenkins build.
I am using multibranch pipeline plug-in to define the build on Jenkins server.

As I am doing only mock set-up for now, the pipeline job is very simple and looks as follows. Can someone explain where I am going wrong?
The log below clearly reports that it is checking out test3 branch. So, I expect repository to be checked out correctly.

node {

stage 'build'

sh "pwd"

sh "ls ${workspace}@script"

sh "echo $PATH"

sh "cat  ${workspace}@script/simple.csh"

sh "csh  ${workspace}@script/simple.csh"

 

stage 'merge'

sh 'git stash'

sh 'git checkout master'

sh 'git merge test3'

sh 'git commit -am "Merged test3 branch to master"'

sh "git push origin master"

}


The script executes all the way till "git stash" and at this point, it reports error.
I have attached the entire log.

Branch indexing
> git rev-parse --is-inside-work-tree # timeout=10
Setting origin to git@hd1:testing
> git config remote.origin.url git@hd1:testing # timeout=10
Fetching origin...
Fetching upstream changes from origin
> git --version # timeout=10
> git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/master
Seen branch in repository origin/test
Seen branch in repository origin/test1
Seen branch in repository origin/test2
Seen branch in repository origin/test3
Seen branch in repository origin/test4
Seen branch in repository origin/testx
Seen 7 remote branches

> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@hd1:testing # timeout=10
Fetching upstream changes from git@hd1:testing
> git --version # timeout=10
> git fetch --tags --progress git@hd1:testing +refs/heads/*:refs/remotes/origin/*
Checking out Revision f5eabd27c25242cc35d0b597537c3a3bcec8f54f (test3)

> git config core.sparsecheckout # timeout=10
> git checkout -f f5eabd27c25242cc35d0b597537c3a3bcec8f54f
> git rev-list 18552ecf03f27679cb0d88f28c096d5c7ec33d99 # timeout=10
[Pipeline] node Running on master in /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A
[Pipeline] { [Pipeline] stage (build) Using the ‘stage’ step without a block argument is deprecated
Entering stage build
Proceeding
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ pwd

/var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ ls /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A@script
avalon_asrts.sv
binding.sv
dir1
Jenkinsfile
Just_Checking
simple.csh
source.csh
tb_avalon_asrts.sv
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ echo /sbin:/usr/sbin:/bin:/usr/bin
/sbin:/usr/sbin:/bin:/usr/bin
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ cat /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A@script/simple.csh
#!/bin/csh -f -e -x
echo "welcome to Jenkins from test2 branch"
\rm -f t
echo "junk" > t
exit 0
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ csh /var/lib/jenkins/workspace/an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A@script/simple.csh
welcome to Jenkins from test2 branch
[Pipeline] stage (merge) Using the ‘stage’ step without a block argument is deprecated
Entering stage merge
Proceeding
[Pipeline] sh [an_example_test3-26UQSYQ445FSBP4QRKEWLPQCJH545MLQVD6B552CIGPOXLZO4G5A] Running shell script
+ git stash
fatal: Not a git repository (or any of the parent directories): .git
[Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 128
Finished: FAILURE
Reply all
Reply to author
Forward
0 new messages