You don't say what the failure is, but I suspect the "matlab" command may not be found. Jenkins is probably running as a different user than you (likely as user "jenkins"), and this user does not have matlab on its path. You could address this by either adding the necessary elements to the Jenkins user's path, or giving the full path to matlab.

Eric

On 7/8/2014 10:03 AM, Martin Bergene Johansen wrote:

In the ‘Build’ section, add a build step called ‘Execute Shell’. When this job runs, it will create a new (and temporary)
    directory, drop everything you’re pulling out of BitBucket into
    that directory and the appropriate subdirectories, and then run
    whatever you put in the execute shell step as if it was a Bash script.

This part is something I’m struggling with. I don’t know how this script should look like.
I have been running

|matlab -nodesktop -nosplash -r "cd /home/username/matlabScriptLocation; 
someMatlabScript; exit"
|

in the Ubuntu terminal, and I managed to run the script specified in the command. I tried to run the same line in Jenkins but it didn’t work. So it seems that I’m doing something wrong. Also, I will now be running a script from BitBucket rather than a location on the machine, so I guess it will require some additional alterations.

I know you said you weren’t familiar with MatLab and BitBucket, but would you by any chance have any educated guesses on how this script should look like?

​


kl. 14:34:08 UTC+2 tirsdag 8. juli 2014 skrev Rob Mandeville følgende:

    You’ll want to go through the documentation at
    http://jenkins-ci.org/, clearly.

    I’m assuming that you have BitBucket and MatLab (two technologies
    that I am unfamiliar with) on a Ubuntu box.  I’m also assuming
    that you know BitBucket, MatLab, and Ubuntu.  Frankly, I’m not
    sure what TAP is, so I can’t help you there.

    You can read how to install Jenkins at
    https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins
    <https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins>, in the
    section “Installation”.  Basically, you download jenkins.war
(there’s a link on that page) and run “java –jar jenkins.war”. You’ll have a simple Jenkins server on port 8080. If you don’t
    know how to have that come up every time the machine boots, your
    local sysadmin will know how to make an “init.d script” to make
    that happen.

    Via the Web, go to Manage Jenkins->Manage Plugins.  If you only
    reach the internet through a proxy, select the ‘Advanced’ tag and
    set the HTTP Proxy configuration; see your admin as needed.

    Select the ‘Available’ tab.  Search for the plugin called
    ‘Bitbucket pullrequest builder plugin’  Click the box to put a
    checkmark on it, then get to the bottom of the page and click
    ‘Install without restart’.  This should install the BitBucket plugin.

    Now you’re ready to create a build job.

    Get back to the main screen by clicking the word ‘Jenkins’ in the
    top left hand corner (to my knowledge, this always works).  Click
    ‘New Item’ to create a new job. Give it a name, and select ‘Build
    a free-style software project’ and you will go to the
    configuration page.

    Your first goal here is to just get the matlab job to run.

Go to the ‘Source Code Management’ section and select BitBucket. I don’t know what options it will have, but whatever they are,
    they should make sense to an expert in BitBucket.  Select the
    options needed.

In the ‘Build’ section, add a build step called ‘Execute Shell’. When this job runs, it will create a new (and temporary)
    directory, drop everything you’re pulling out of BitBucket into
    that directory and the appropriate subdirectories, and then run
    whatever you put in the execute shell step as if it was a Bash script.

    Once you have the configuration the way that you want it, click
‘save’ at the bottom and you’ll get a page for the job itself. Click the ‘build’ button (it looks like a clock with a ‘Play’
    triangle, as you are actually scheduling a build).

    On the left, there will be a ‘Build history’ section. The ‘ball’
    to the left will be blue if it succeeds (there’s a plugin to make
    that green if you prefer) or red if it fails.  There is yellow for
    ‘unstable’, but you won’t be using that at this point.

    Very likely, the first run will hand you a red ball back. Like
    anything else in software, you’re gonna have to debug.  Click on
    the build you just ran, then on ‘Console output’, to see what
    happened.  Once you know what happened, go back two pages to the
    page for the job itself, and select ‘Configure’ to go back to the
    configuration page.  You’ll cycle between running a job, checking
    the console output, and editing the configuration to get it right.

    You may have to take several tries to get this script to work.  It
    will have mostly the same environment of whoever or whatever ran
    the ‘java –jar Jenkins.war’ command, so the environment will be
    different if you start it from your command line versus it being
    started from an init.d script.  If, for example, it complains that
    it can’t find MatLab, go into the shell step and add the directory
    MatLab is in to the path before running the command.  If you have
    trouble here, work with your local shell script expert; that’s all
    this step is doing.

    Once you have that all set and are getting blue results back,
    check the output again to make sure that it’s actually doing what
    you want it to do.  Once you’re assured of that, you’re probably
    going to want to automate running this.  Back in the
    configuration, go to ‘Build Triggers’.  You probably want to use
    ‘Build periodically’ (build it every day or every two hours, for
    instance), or ‘Poll SCM’ (build every time somebody checks new
    stuff into BitBucket.  Rely on the little blue help icons on the
    right to walk yourself through this.

    I’ll leave the ‘tutorial’ at this point, as the next steps (if
    any) depend on what you want to do.  There are a set of
    ‘Post-Build Actions’ that can read the output to determine if
    tests passed, publish output from certain files or directories, or
    send email to various people when the job finishes (or even just
    when it fails).  What you’re going to do here depends on what your
    needs are, and I can’t possibly cover every possibility.

    --Rob

    *From:*jenkins...@googlegroups.com <javascript:>
    [mailto:jenkins...@googlegroups.com <javascript:>] *On Behalf Of
    *Martin Bergene Johansen
    *Sent:* Tuesday, July 08, 2014 4:32 AM
    *To:* jenkins...@googlegroups.com <javascript:>
    *Subject:* Jenkins, BitBucket and MatLab on Ubuntu

    Hello

    I’m new to Jenkins, BitBucket, MatLab and Ubuntu, and I’m in a
    project group that needs to run MatLab scripts from BitBucket,
    using Jenkins.

    Some details:

    ·Ubuntu 14.04

    ·MatLab r2014a

    ·We wish to use the BitBucket Pull Request Builder Plugin

    ·We wish to use TAP for feedback

    What I need, is help to put all of this together.

    I’m also sorry to bother you with this request, but after
    searching the web for several hours i still have trouble figuring
    this out.

    Like I said, I’m new to all of this, so it would be nice if you
    could explain it like I’m 5.

    Best regards
    Martin

    ​

-- 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 jenkinsci-use...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.

    Click here
    
<https://www.mailcontrol.com/sr/aq9OImpqXNfGX2PQPOmvUqy%218K4P2+305Sw310LJM9PF69rQ1sPRJ8uAsLSybwr09D5z0CtC0Z5+U88fPeCTtg==>
    to report this email as spam.


    ------------------------------------------------------------------------
    This e-mail and the information, including any attachments it
    contains, are intended to be a confidential communication only to
    the person or entity to whom it is addressed and may contain
    information that is privileged. If the reader of this message is
    not the intended recipient, you are hereby notified that any
    dissemination, distribution or copying of this communication is
    strictly prohibited. If you have received this communication in
    error, please immediately notify the sender and destroy the
    original message.

    Thank you.

    Please consider the environment before printing this email.

--
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 jenkinsci-users+unsubscr...@googlegroups.com <mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
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 jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to