Workflow DSL with git (and others)

555 views
Skip to first unread message

Sven Erik Knop

unread,
May 15, 2015, 1:19:39 PM5/15/15
to jenkin...@googlegroups.com
Hi,

two-part question:

I am trying to add another SCMStepDescriptor but I am getting stuck at trivial problems. Maybe someone can help me out:

1.
I cannot even get Git to work in a standard Jenkins installation (1.612) with any visible Git plugin installed. I get the error

 No such DSL method git found among [archive, bat, build, catchError, dir, echo, error, fileExists, input, load, mail, node, parallel, pwd, readFile, retry, sh, sleep, stage, step, timeout, tool, unarchive, waitUntil, withEnv, writeFile, ws]

SVN works just fine.

2.
When I am trying to develop a new SCMStepDescriptor, I cloned jenkins/workflow-plugin, created the necessary bits in Eclipse via mvn and added my code, but I get the same problem in that my descriptor is not visible. I am starting my modified Jenkins instance up from the directory 

workflow-plugin/aggregator

Is that the right place to start from? This seems to be the only project that loads all required parts, but again, it does not pick up my new StepDescriptor.

Thanks for any help

Sven Erik

Jesse Glick

unread,
May 15, 2015, 2:41:14 PM5/15/15
to Jenkins Dev
On Fri, May 15, 2015 at 1:19 PM, Sven Erik Knop <sek...@gmail.com> wrote:
> No such DSL method git found among [archive, bat, build, catchError, dir,
> echo, error, fileExists, input, load, mail, node, parallel, pwd, readFile,
> retry, sh, sleep, stage, step, timeout, tool, unarchive, waitUntil, withEnv,
> writeFile, ws]

Sounds like workflow-scm-step is not actually installed. Check that
you are using latest versions of all plugins.

> When I am trying to develop a new SCMStepDescriptor, I cloned
> jenkins/workflow-plugin

Huh?? You just need to create a fresh Jenkins plugin from archetype,
then add a dependency on workflow-scm-step. Create an SCMStep subclass
with an SCMStepDescriptor, then

mvn clean hpi:run

Sven Erik Knop

unread,
May 21, 2015, 11:34:31 AM5/21/15
to jenkin...@googlegroups.com
Hi Jesse,

thanks for coming back to me.

On Friday, 15 May 2015 19:41:14 UTC+1, Jesse Glick wrote:
On Fri, May 15, 2015 at 1:19 PM, Sven Erik Knop <sek...@gmail.com> wrote:
>  No such DSL method git found among [archive, bat, build, catchError, dir,
> echo, error, fileExists, input, load, mail, node, parallel, pwd, readFile,
> retry, sh, sleep, stage, step, timeout, tool, unarchive, waitUntil, withEnv,
> writeFile, ws]

Sounds like workflow-scm-step is not actually installed. Check that
you are using latest versions of all plugins.


Not sure what is wrong with the Git workflow plugin, all plugins are on the latest release. Not a problem at the moment.


 
> When I am trying to develop a new SCMStepDescriptor, I cloned
> jenkins/workflow-plugin

Huh?? You just need to create a fresh Jenkins plugin from archetype,
then add a dependency on workflow-scm-step. Create an SCMStep subclass
with an SCMStepDescriptor, then

mvn clean hpi:run

I added the DSL for Perforce to the P4 Plugin at the moment, that seems to work fine.

Now I am trying to add a publish step. I am probably misunderstanding something here.

My DSL code looks like this

node {
  
  p4_stream charset: 'none', credential: '634a31d2-bd60-4c39-bf84-b09f057c5431', stream: '//stream/main'

  step([$class: 'TagNotifier', rawLabelDesc: 'Jenkins post-build label.', rawLabelName: 'jenkins-stream-test'])

}

The TagNotifier class is part of the P4 Plugin to perform a post-build step of labelling the source in Perforce. This works fine if I create a standard Freestyle Project.

In the DSL TagNotifier gets invoked but it lacks in two respects:

1. The "run" object that gets invoked has a getResult() value of null (preventing me from labelling only for successful builds)
2. The resulting build normally adds an extra attachment that links to a label page. The URL is incomplete. Usually the URL looks like this:

http://localhost:8080/jenkins/job/<build-name>/<job-number>/tagBuild/ 
for example:

in my DSL case it is 

and the link points into nowhere.

Is there something missing in the DSL code? 

Cheers

Sven Erik

Jesse Glick

unread,
May 27, 2015, 6:16:43 PM5/27/15
to Jenkins Dev
On Thu, May 21, 2015 at 11:34 AM, Sven Erik Knop <sek...@gmail.com> wrote:
> The "run" object that gets invoked has a getResult() value of null

Sure, because the flow is still running. It will eventually become
SUCCESS if nothing goes wrong later.

> (preventing me from labelling only for successful builds)

If the build failed with an exception, the rest of the flow should not
run, unless you are using a try-block.

See also the catchError step, which is a way to run a publisher even
if the build is _not_ successful.

> Usually the URL looks like this:
>
> http://localhost:8080/jenkins/job/<build-name>/<job-number>/tagBuild/
> for example:
> http://localhost:8080/jenkins/job/p4-direct/2/tagBuild/
>
> in my DSL case it is
> http://localhost:8080/jenkins/tagBuild/
>
> and the link points into nowhere.

Well debug whatever code constructs that URL and see why it is
omitting part of it. I have no idea offhand.
Reply all
Reply to author
Forward
0 new messages