Hello,
I have made some progress on this (much slower than I would like) and would
like to document some answers to my earlier questions + add some new
questions / problems I've run into. Hopefully somebody here can help me out?
On Friday, 27 May 2016 17:17:21 UTC+2, Pieter-Jan Busschaert wrote:
>
> Can someone here please answer these questions:
>
> - Where should I store the Jenkinsfile? Is there 1 file for all
> branches or should there be 1 file in each branch?
>
> Putting Jenkinsfile into trunk/projectA seems to work OK.
>
> - Which URL should I configure in the job page as the "project
> repository base"?
>
> Using the repository root seems to work OK. Also, the credentials for the
svn:externals also don't need to be repeated as "extra credentials" with
pipeline, which I like.
>
> - What patterns should I put in the include/exclude branches boxes?
>
> trunk/projectA,branches/*/projectA seems to work OK.
>
> - Currently we create 2 types of builds for each project : 1
> incremental build which runs after each commit (build + test), 1 clean
> build which runs at night (clean + build + test + create installers). How
> would we do something like that ? Would that need 2 Jenkinsfiles per
> project ?
>
> No solution for this yet. As there is clearly only 1 Jenkinsfile per
branch (I didn't find any config option to specify a different filename),
probably I'd have to make my Jenkinsfile parameterized and then create
multiple multi-branch projects, one with the "incremental" parameter set to
true, one with that parameter set to false. Is this a reasonable approach
or is there a better one? I have seen a few similar questions to this list
the last few days, but the replies are mostly from people who want
clarifications on why you would want/need multiple Jenkins jobs for a
single source folder. I hope my usecase is clear?
Now, some documentation about what I tried initially after reading the
tutorial and had to change because it didn't work. This might be useful as
new-user input for any update to documentation / tutorial.
I started by just putting the current "execute windows bat script" contents
in actual .bat files and created a Jenkinsfile based on the original build
steps (just put them in the same order):
node {
stage 'Checkout'
checkout scm
stage 'Build'
bat 'call jenkins_build.bat'
stage 'Test'
bat 'call jenkins_test.bat'
stage 'Collect testreports'
step ([ $class: 'XUnitPublisher', ... ]) // generated by "Pipeline
syntax" utility
stage 'Email notifications'
step ([ $class: 'Mailer', ...]) // generated by "Pipeline syntax" utility
}
Now, what didn't work in the above and I was able to solve:
1. %WORKSPACE% is not available for pipeline plugins, so I had to use
the workaround described in
https://issues.jenkins-ci.org/browse/JENKINS-33511
2. However, the resulting %WORKSPACE% variable doesn't really work
as-is, probably because there is a newline character at the end. Doing
something like "set WORKSPACE2=%WORKSPACE%" fixes (probably removing the
newline).
3. No timestamps in the console log, so wrap everything in a big
timestamps{} block.
4. I was not receiving any email notifications for failures, because the
pipeline just stops.
1. Putting everything in a try{} block and the email notification stage
in a finally{} block did not solve it.
2. I had to put a catch{} block in between where I explicitly set
currentBuild.result = "FAILURE"
So, my current Jenkinsfile is something along these lines:
node {
timestamps {
try {
stage 'Checkout'
checkout scm
// %WORKSPACE% workaround, see
https://issues.jenkins-ci.org/browse/JENKINS-33511
bat 'cd > workspace.txt'
env.WORKSPACE = readFile('workspace.txt')
bat 'del workspace.txt'
stage 'Build'
bat 'call jenkins_build.bat'
stage 'Test'
bat 'call jenkins_test.bat'
stage 'Collect testreports'
step ([ $class: 'XUnitPublisher', ... ]) // generated by "Pipeline
syntax" utility
} catch (caughtError) {
err = caughtError // not sure if this line is really
needed ?
currentBuild.result = "FAILURE"
} finally {
stage 'Email notifications'
step ([ $class: 'Mailer', ...]) // generated by "Pipeline syntax"
utility
}
}
}
However, my project doesn't build yet. It appears Microsoft Visual Studio
2012 has an issue with running inside folders with a "%" in the name. The
workspace folder is named according to a sanitized branch location. In my
case this is "trunk%2FprojectA". This is a valid foldername on windows, but
certainly not common and apparently not supported by VS2012 command line
tools. When specifying an include directory with /I"libraryX\include", I
get these errors while building:
cl : Command line error D8038: invalid argument
'C:\jenkins\workspace\pipeline_test\trunk%2FprojectA\libraryX\include'
After some debugging it seems to be caused by the % sign. If I rename the
folder on my own build pc to have a % in the name, I get the same error. I
did not find a way to specify or alter the way a sanitized workspace
location is generated. However, I did find a similar issue/request reported
here: https://issues.jenkins-ci.org/browse/JENKINS-34564 and while looking
that one back up, I found
https://issues.jenkins-ci.org/browse/JENKINS-30744 which actually contains
a workaround. I'll try this workaround right now.
Anyway, in summary, I must say it seems to me the relevant documentation on
how to convert normal jobs to pipeline jobs is quite scattered around
(tutorial.md, blogs, mailinglist, issue tracker, ...). It seems flexible
enough, but I don't like putting in all the workarounds, because the
Jenkinsfile is supposed to be simple, not containing a lot of logic.
--
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/01292ec4-d8a5-44b1-9428-c61ec7c3b963%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.