Tuesday, January 15, 2013

clearcase setview command

cleartool setview command when executes will spawn a new shell, so if it is executed within a shell it would escape and won't return :-) . You need to use -exe

http://www-01.ibm.com/support/docview.wss?uid=swg21119859


Problem(Abstract)

This technote explains why setting into an IBM® Rational® ClearCase® view from within a UNIX® or Linux® shell script does not process the remaining commands in that script.

Cause

When running the sample script below, all commands executed after the cleartool setviewcommand are not processed because cleartool setview spawns a new shell:

#!/bin/sh
/usr/atria/bin/cleartool setview cmview
/usr/atria/bin/cleartool pwv
/usr/atria/bin/cleartool lsview
cd /vob/transition/Admin_transition
/usr/atria/bin/cleartool mkbrtype -global -nc 02b456
In the above script any commands that appear after the execution of cleartool setview cmvieware not processed because a shell is spawned off with exec(), which replaces the current program with a new program.
This means current process's text and code segments, which in this case is the script that contains all the commands, is replaced by the program getting executed, which is the shell invoked by runningcleartool setview cmview. Hence, none of the commands are processed beyond the point of invocation of the setview.

Resolving the problem

This is the expected behavior.
WORKAROUNDS:
  1. Run cleartool setview prior to calling the script:

    Example:

    $ cat /tmp/script.sh
    #!/bin/sh
    /usr/atria/bin/cleartool pwv

    $ cleartool setview new_view
    [new_view]$ /tmp/script.sh
    Working directory view: new_view
    Set view: new_view
  2. Run the cleartool setview command and exec into the script:

    Example:

    $ cleartool setview -exec /tmp/script.sh new_view
    Working directory view: new_view
    Set view: new_view

-------------------

A quick example is:

cleartool setview -exec "/usr/local/bin/myscript.sh" $myview 


Friday, January 11, 2013

more headless jenkins under Mac OS X 10.x

Steps to create a headless Slave Jenkins Mac OS X

1. Install Java VM or JDK
    Downloading .DMG from Oracle Java site. Install
2. Install Apple X Code development plus command line package
    Download from Apple Developers site
3. Connect under-setup Jenkins Mac Slave to Jenkins Master through web browser
4. Create a Mac Slave Node on Master
5. From Slave, connect to Master from Mac Slave Node using command line:
    javaws http://<your jenkins master>:8080/computer/<YOUR SLAVE MACHINE NAME>/slave-agent.jnlp
or if the slave is headless:
    java -jar slave.jar -jnlpUrl http://<your jenkins master>:8080/computer/<YOUR SLAVE MACHINE NAME>/slave-agent.jnlp

6. The above step #5 will fail as expected

7. Create a .plist file org.jenkins-ci.plist for launchDaemons in
    /Library/LaunchDaemons/<create a dir name here>
All paths here are specific for my system.
---

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>StandardOutPath</key>
    <string>/Users/Shared/build-slave/jenkins.log</string>
    <key>StandardErrorPath</key>
    <string>/Users/Shared/build-slave/jenkins.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>JENKINS_HOME</key>
<string>/Users/Shared/build-slave</string>
</dict>
<key>GroupName</key>
<string>daemon</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.jenkins-ci</string>
<key>ProgramArguments</key>
<array>
                <string>/bin/bash</string>
<string>/Library/Application Support/build-slave/start-headless-jenkins-slave.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>your user</string>
        <key>SessionCreate</key>
<true />
</dict>
</plist>
---


8. Create a LaunchDaemon script start-headless-jenkins-slave.sh in
    /Library/Application Support/<create a dir name here>
----
#!/bin/bash
/usr/bin/java -jar slave.jar -jnlpUrl http://<your jenkins master:8080>/computer/<your mac slave>/slave-agent.jnlp
----

9. Create a launchDaemon script to start jenkins headless slave in case you want to do it manually, test, etc.
sudo launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist

10. Put the command line in /etc/launchd.conf to start everytime the system reboots
...
launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist
...

------
some examples of launchctl:

sudo launchctl list
sudo launchctl unload -w /System/Library/LaunchDaemons/finger.plist
sudo launchctl load -w /System/Library/LaunchDaemons/finger.plist
...

http://ss64.com/osx/launchctl.html
http://www.dowdandassociates.com/content/howto-set-environment-variable-mac-os-x-etclaunchdconf

Thursday, January 10, 2013

Headless Jenkins in Mac OS X 10.8

Working on the Launch scripts, but for now save all relevant and related links:

https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins
https://wiki.jenkins-ci.org/display/JENKINS/Thanks+for+using+OSX+Installer
https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins

Daemons:
http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html
http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
http://developer.apple.com/library/mac/#technotes/tn2083/_index.html


https://issues.jenkins-ci.org/browse/JENKINS-15697?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab

https://gist.github.com/813900
http://www.slideshare.net/demetra512/jenkins-guide
http://vincemansel.com/blog/2012/11/03/an-end-to-end-automated-build-and-test-environment-part-2/
http://mattonrails.wordpress.com/2011/06/08/jenkins-homebrew-mac-daemo/
http://wiki.wocommunity.org/display/documentation/Installing+and+Configuring+Jenkins
http://www.paulruffle.com/osx.htm