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* <http://stacktrace.jenkins-ci.org/search?query=Finished>: FAILURE



On Thursday, 9 February 2017 21:49:40 UTC+5:30, [email protected] wrote:

> 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.
>
>

-- 
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/552890b3-4c0c-45f6-a5db-7df3c60b5bdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to