On Tue, Apr 30, 2013 at 9:36 PM, Gavin <[email protected]> wrote:

> Hey guys,
>
> I'm trying to make a simple plugin that integrates with our inhouse
> deployment system. The plan will be for a given build for any job, to be
> able to fire off a task which in turn talks to our inhouse apis.
>
> Right now I have an Action setup that hits a common resource (stapler? A
> doBlah function), and inside there I am firing off a lightweight task.
>
> Hudson.getInstance().getQueue().schedule( new DeployerTask( run, env ), 0
> );
>
> Everything there seems to work fine, but when it shows up under the
> executors list, it has a bad link to "/console". I've tracked this down (I
> think) to executors.jelly which uses buildProgressBar.jelly, and that has
> the link 'href="${rootURL}/${build.url}console"'
> I can't figure out how to set the .url for this.
>
> Can someone point me in the right direction?
>
> Additionally, I'm thinking this might not be the best way to handle this
> problem. I'm hoping I missed something and there is an extension point that
> can be triggered by an action to update a build (add some simple meta
> data/html? and maybe update the log) and have a long running task (Queue?)
>
> Gavin
>
>
I did something similar to this, at least for adding metadata to a build.
 I implemented it as a BuildWrapper extension that consumes an artifact
file of the build and appends some actions that I can then search on via
the normal xpath api.  ( I think I copied most of this from another plugin,
but can't remember which).  This is triggered by enabling it in the build
config; you could probably also add a build parameter to cause it (not) to
fire if you want to add more control.

I'm not sure how you would set up the long running action, but you should
be able to queue up in the tearDown.

The meat of it is in two functions on the BuildWrapper subclass:
 setUp which adds the tearDown override to call annotateBuild.  readFile
just returns a custom action:

    @Override
    public Environment setUp(final AbstractBuild build, final Launcher
launcher, final BuildListener listener)
            throws IOException, InterruptedException {
        if (build instanceof MatrixRun) return new Environment() { };
        return new Environment() {
            @Override
            public boolean tearDown(final AbstractBuild build, final
BuildListener listener) throws IOException, InterruptedException {
                return annotateBuild(build, listener);
            }
        };
    }


    private boolean annotateBuild(final AbstractBuild build, final
BuildListener listener) {

        try {
            FilePath setupDetailsFile =
build.getWorkspace().child(SETUP_DETAILS_FILE);

            if (!setupDetailsFile.exists()) {
                setupDetailsFile =
build.getWorkspace().child(ARCHIVE_DIR).child(SETUP_DETAILS_FILE);
                if (!setupDetailsFile.exists()) {
                    listener.getLogger().println("BuildAnnotator could not
find "+SETUP_DETAILS_FILE);
                    return true;
                }
            }
            build.addAction(readFile(setupDetailsFile));

            // not sure if I need this
            build.save();
        } catch (IOException ioe) {
        } catch (InterruptedException ioe) {
        } catch (NullPointerException npe) {
        }
        return true;
    }


-- 
Marc MacIntyre

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to