The problem with hacking into the git-plugin and calling a separate script is that the git-plugin for Jenkins is core to a lot of the Pipeline plugins we also want to move forward with. We have to maintain the altered git-plugin through updates as that plugin is under active development. And the external script has to remain working. And the whole thing has to be installed every time a Jenkins server is recreated…
Not ideal. Ideal would be a new plugin that listens to the same /git/notifyCommit?url=URL commit hook sent by bitbucket to the git-plugin on Jenkins to trigger a build – to listen and act on that notifyCommit in the case where Jenkins does NOT have a job that listens for that repo string sent by “url=URL”.
That package sent looks like:
So… Simple, yes? It turns out the Listener method in the hudson.plugin.git.GitStatus file has it’s Listener method extend ExtensionPoint – designed for exactly this parallel catching of the notifyCommit:
Creating this new plugin starts with installing maven and making it available to be used:
down load https://maven.apache.org/download.cgi install https://maven.apache.org/install.html add maven to .profile: export M2_HOME=/opt/apache-maven-3.3.9 export M2=$M2_HOME/bin export PATH=$M2:$PATH
Then editing ~/.m2/setting.xml and placing in there:
org.jenkins-ci.tools jenkins true repo.jenkins-ci.org http://repo.jenkins-ci.org/public/ repo.jenkins-ci.org http://repo.jenkins-ci.org/public/
Then run mvn to create the framework:
mvn -cpu hpi:create
Accept the default jenkins-ci group,
enter the name for the plugin,
cd into the created directory,
and run
mvn clean package
Import it into your favorite IDE (intelliJ for myself), and gradually move over the GitStatus.java pieces needed, resolving the imports as you go and packaging the hpi jenkins plugin file to verify it actually builds.
Then I coded the steps we had in python in an external script into java calls to the Jenkins API
It all works, just adding back in code to trigger the build for the job we just created in Jenkins
This should allow leaving the git-plugin completely alone and adding in this functionality on top of it. Once it’s cleans up and ready for open source release, I’ll post it. I didn’t intend to be part of AOL – I would have thought, oh, like Yahoo, only dial-up. Outdated… Not dso much. The culture is actually way better than a larger company would lead you to expect – intentionally very good. One of the objectives is to release as much of what we do into the Open Source community as possible.
—doug