|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Use this script to create a Jenkins job |
| 4 | + |
| 5 | +die () { |
| 6 | + echo "$*" >&2 |
| 7 | + exit 1 |
| 8 | +} |
| 9 | + |
| 10 | +test $# = 2 || |
| 11 | +die "Usage: $0 <job-name> (<config.xml> | --deploy-to-imagej <github-URL>)" |
| 12 | + |
| 13 | +name="$1" |
| 14 | +jenkinsurl="http://jenkins.imagej.net:8080" |
| 15 | +createurl="$jenkinsurl/view/Fiji/createItem?name=$name" |
| 16 | + |
| 17 | +case "$2" in |
| 18 | +--deploy-to-imagej=*) |
| 19 | + name2="$(echo "$name" | tr '_' ' ')" |
| 20 | + url="${2#--deploy-to-imagej=}" |
| 21 | + config="$(cat << EOF)" |
| 22 | +<project> |
| 23 | + <actions/> |
| 24 | + <description>Builds and deploys $name2 every time changes are pushed to the <a href="$url">$name2 Git repository</a>.</description> |
| 25 | + <logRotator class="hudson.tasks.LogRotator"> |
| 26 | + <daysToKeep>-1</daysToKeep> |
| 27 | + <numToKeep>15</numToKeep> |
| 28 | + <artifactDaysToKeep>-1</artifactDaysToKeep> |
| 29 | + <artifactNumToKeep>-1</artifactNumToKeep> |
| 30 | + </logRotator> |
| 31 | + <keepDependencies>false</keepDependencies> |
| 32 | + <properties> |
| 33 | + <hudson.security.AuthorizationMatrixProperty> |
| 34 | + <permission>hudson.model.Item.Workspace:anonymous</permission> |
| 35 | + <permission>hudson.model.Item.Workspace:authenticated</permission> |
| 36 | + <permission>hudson.model.Run.Update:authenticated</permission> |
| 37 | + <permission>hudson.model.Item.Configure:authenticated</permission> |
| 38 | + <permission>hudson.scm.SCM.Tag:authenticated</permission> |
| 39 | + <permission>hudson.model.Item.Delete:authenticated</permission> |
| 40 | + <permission>hudson.model.Item.Build:authenticated</permission> |
| 41 | + <permission>hudson.model.Item.Read:anonymous</permission> |
| 42 | + <permission>hudson.model.Item.Read:authenticated</permission> |
| 43 | + <permission>hudson.model.Run.Delete:authenticated</permission> |
| 44 | + </hudson.security.AuthorizationMatrixProperty> |
| 45 | + <hudson.plugins.disk__usage.DiskUsageProperty plugin="[email protected]"/> |
| 46 | + </properties> |
| 47 | + <scm class="hudson.plugins.git.GitSCM" plugin="[email protected]"> |
| 48 | + <configVersion>2</configVersion> |
| 49 | + <userRemoteConfigs> |
| 50 | + <hudson.plugins.git.UserRemoteConfig> |
| 51 | + <name>origin</name> |
| 52 | + <refspec>+refs/heads/*:refs/remotes/origin/*</refspec> |
| 53 | + <url>$url</url> |
| 54 | + </hudson.plugins.git.UserRemoteConfig> |
| 55 | + </userRemoteConfigs> |
| 56 | + <branches> |
| 57 | + <hudson.plugins.git.BranchSpec> |
| 58 | + <name>master</name> |
| 59 | + </hudson.plugins.git.BranchSpec> |
| 60 | + </branches> |
| 61 | + <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> |
| 62 | + <submoduleCfg class="list"/> |
| 63 | + <extensions> |
| 64 | + <hudson.plugins.git.extensions.impl.PerBuildTag/> |
| 65 | + </extensions> |
| 66 | + </scm> |
| 67 | + <canRoam>true</canRoam> |
| 68 | + <disabled>false</disabled> |
| 69 | + <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> |
| 70 | + <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> |
| 71 | + <jdk>(Default)</jdk> |
| 72 | + <triggers> |
| 73 | + <hudson.triggers.SCMTrigger> |
| 74 | + <spec>@yearly</spec> |
| 75 | + <ignorePostCommitHooks>false</ignorePostCommitHooks> |
| 76 | + </hudson.triggers.SCMTrigger> |
| 77 | + </triggers> |
| 78 | + <concurrentBuild>false</concurrentBuild> |
| 79 | + <builders> |
| 80 | + <hudson.tasks.Shell> |
| 81 | + <command>git clean -dfx</command> |
| 82 | + </hudson.tasks.Shell> |
| 83 | + <hudson.tasks.Shell> |
| 84 | + <command>mvn -DupdateReleaseInfo=true -Pdeploy-to-imagej deploy</command> |
| 85 | + </hudson.tasks.Shell> |
| 86 | + </builders> |
| 87 | + <publishers> |
| 88 | + <hudson.tasks.ArtifactArchiver> |
| 89 | + <artifacts>**/target/*.jar</artifacts> |
| 90 | + <latestOnly>false</latestOnly> |
| 91 | + <allowEmptyArchive>false</allowEmptyArchive> |
| 92 | + </hudson.tasks.ArtifactArchiver> |
| 93 | + <hudson.tasks.Mailer plugin="[email protected]"> |
| 94 | + <recipients>[email protected]</recipients> |
| 95 | + <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild> |
| 96 | + <sendToIndividuals>true</sendToIndividuals> |
| 97 | + </hudson.tasks.Mailer> |
| 98 | + <org.jenkinsci.plugins.emotional__jenkins.EmotionalJenkinsPublisher plugin="[email protected]"/> |
| 99 | + <hudson.plugins.ircbot.IrcPublisher plugin="[email protected]"> |
| 100 | + <targets class="empty-list"/> |
| 101 | + <strategy>FAILURE_AND_FIXED</strategy> |
| 102 | + <notifyOnBuildStart>false</notifyOnBuildStart> |
| 103 | + <notifySuspects>false</notifySuspects> |
| 104 | + <notifyCulprits>false</notifyCulprits> |
| 105 | + <notifyFixers>false</notifyFixers> |
| 106 | + <notifyUpstreamCommitters>false</notifyUpstreamCommitters> |
| 107 | + <buildToChatNotifier class="hudson.plugins.im.build_notify.DefaultBuildToChatNotifier" plugin="[email protected]"/> |
| 108 | + <matrixMultiplier>ONLY_CONFIGURATIONS</matrixMultiplier> |
| 109 | + <channels/> |
| 110 | + </hudson.plugins.ircbot.IrcPublisher> |
| 111 | + </publishers> |
| 112 | + <buildWrappers/> |
| 113 | +</project> |
| 114 | +EOF |
| 115 | + ;; |
| 116 | +*) |
| 117 | + config="$(cat "$2")" || |
| 118 | + die "Could not read $2" |
| 119 | + ;; |
| 120 | +esac |
| 121 | +
|
| 122 | +#crumb="$(curl "$jenkinsurl/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)")" |
| 123 | +curl --netrc -XPOST -H Content-Type:text/xml -d "$config" "$createurl" |
0 commit comments