Hi,

Thanks for describing your workflow and posting your script.
You want to do some non-trivial stuff in your script, but I think it is
doable.

You mentioned that you are doing this on Windows, so you are correctly
invoking 'bat' to run commands.  You won't be able to get away from doing
that.

You've probably already done this, but I strongly advise you to bookmark
this link:

https://github.com/jenkinsci/pipeline-plugin/#getting-started

That is the best starting point for all the docs and examples
related to pipeline.  Pipeline is a work in progress, so things are not
perfect,
but they are definitely improving every day.

The next thing I would advise you to do, is to take a look at this pipeline
which I
wrote:

https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy

That is a non-trivial build -> test -> report results workflow.  It is
Unix-based,
so it isn't Windows, but you'll get some ideas (hopefully!).

Also, bookmark this link which I wrote which talks about global variables
in pipelines:

https://groups.google.com/d/msg/jenkinsci-users/P7VMQQuMdsY/bHfBDSn9GgAJ


I'll take a whack at trying to answer some of your questions.

The 'git' pipeline step is basically only used to checkout stuff.

If you want to see all the parameters you can specify with it,
then go to the screen for configuring your job, and do:

Pipeline
      -> Snippet Generator
            -> Sample Step
                  -> git
                       -> Generate Groovy

The snippet generator will show you what parameters you can add to the git
command.  Using the snippet generator will help you a lot in terms
of figuring out how to use pipeline steps.  It is not a comprehensive API
reference, but it is better than nothing.

Now, in terms of running bat commands, I think you are on the right track.

If you want to take a look at how the bat command is implemented, look
at these two files:

https://github.com/jenkinsci/workflow-durable-task-step-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/BatchScriptStep.java
https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java

It looks like the bat step runs the command you specify under "cmd /c",
and then echoes ERRORLEVEL after executing the command.
It is not clear to me if ERRORLEVEL is propagated back up through groovy in
a way in which you can read it in your script.  I am assuming no.

If you go back to the build-test.groovy which I wrote, you will see that
I catch exceptions, since the Bourne shell step doesn't have a return value
which is useful.  I think the WindowsBatchScript step also doesn't have a
useful return value.  I think what you can try doing, is see if the
bat step throws an exception if the underlying Windows command fails.
If that is the case, you can try catching exceptions, like how I did in
build-test.groovy.

Good luck!
--
Craig

On Wed, May 4, 2016 at 9:16 AM, Brent Kilgore <[email protected]>
wrote:

sorry, forgot to paste my script in it's current state:
>
> node {
>
>   stage "Setup"
>    git branch: DEVELOPMENT_BRANCH,
>       url: GIT_REPO
>
>    stage 'Refresh Shared Branch'
>    echo "Refresh ${DEVELOPMENT_BRANCH} from ${UPSTREAM_BRANCH}"
>
>    def ret = bat "git merge ${UPSTREAM_BRANCH}"
>    echo ret
>    if( ret )
>    {
>        input message: 'Merge Conflict detected', ok: 'Merge Resolved'
>    }
>
>    stage 'Build'
>    echo "Incrementally building ${DEVELOPMENT_BRANCH} in ${GIT_WORKSPACE}"
>
>    stage 'unittest'
>    echo "unittesting"
>
> }
>
> On Wednesday, May 4, 2016 at 12:15:23 PM UTC-4, Brent Kilgore wrote:
>>
>>
>>
>>    1. <git checkout localbranch... since im reusing a folder dedicated
>>    for this, this should no-op>
>>    2. git merge upstream-branch
>>    3. if merge conflicts, pause for manual resolution.  <--- this is the
>>    "killer feature" i was wanting from pipelines
>>    4. git push origin localbranch
>>    5. <perform incremental build by executing perl script>
>>    6. <perform unit tests>
>>    7. <email results>
>>
>>
>>

-- 
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/CAG%3DrPVcHcPRP8_FmbsArT-bpYBB3MOdqsXF2%2BZdJw8n%3DMV57PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to