diff --git a/1.1.x/ghpages.sh b/1.1.x/ghpages.sh index e1063ce..e83a358 100644 --- a/1.1.x/ghpages.sh +++ b/1.1.x/ghpages.sh @@ -12,12 +12,46 @@ if ! [ -d docs/target/generated-docs ]; then exit 0 fi -# Find name of current branch +# The script should be executed from the root folder + +ROOT_FOLDER=`pwd` +echo "Current folder is ${ROOT_FOLDER}" + +if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then + echo "You're not in the root folder of the project!" + exit 1 +fi + +# Retrieve properties ################################################################### -branch=$TRAVIS_BRANCH -[ "$branch" == "" ] && branch=`git rev-parse --abbrev-ref HEAD` -target=. -if [ "$branch" != "master" ]; then target=./$branch; mkdir -p $target; fi + +# Prop that will let commit the changes +COMMIT_CHANGES="no" + +# Get the name of the `docs.main` property +MAIN_ADOC_VALUE=$(mvn -q \ + -Dexec.executable="echo" \ + -Dexec.args='${docs.main}' \ + --non-recursive \ + org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) +echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" + +# Get whitelisted branches - assumes that a `docs` module is available under `docs` profile +WHITELIST_PROPERTY="docs.whitelisted.branches" +WHITELISTED_BRANCHES_VALUE=$(mvn -q \ + -Dexec.executable="echo" \ + -Dexec.args="\${${WHITELIST_PROPERTY}}" \ + org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ + -P docs \ + -pl docs) +echo "Extracted '${WHITELIST_PROPERTY}' from Maven build [${WHITELISTED_BRANCHES_VALUE}]" + +# Code getting the name of the current branch. For master we want to publish as we did until now +# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch +CURRENT_BRANCH=$(git symbolic-ref -q HEAD) +CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} +CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} +echo "Current branch is [${CURRENT_BRANCH}]" # Stash any outstanding changes ################################################################### @@ -25,30 +59,65 @@ git diff-index --quiet HEAD dirty=$? if [ "$dirty" != "0" ]; then git stash; fi -# Switch to gh-pages branch to sync it with current branch +# Switch to gh-pages branch to sync it with master ################################################################### git checkout gh-pages +git pull origin gh-pages -for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - cp -rf $f $target - git add -A $target/$file - fi -done - -git add -A README.adoc || echo "No change to README.adoc" -git commit -a -m "Sync docs from $branch to gh-pages" || echo "Nothing committed" - -# Uncomment the following push if you want to auto push to -# the gh-pages branch whenever you commit to branch locally. -# This is a little extreme. Use with care! +# Add git branches ################################################################### -git push origin gh-pages || echo "Cannot push gh-pages" +mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} +if [[ "${CURRENT_BRANCH}" == "master" ]] ; then + echo -e "Current branch is master - will copy the current docs only to the root folder" + for f in docs/target/generated-docs/*; do + file=${f#docs/target/generated-docs/*} + if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then + # Not ignored... + cp -rf $f ${ROOT_FOLDER}/ + git add -A ${ROOT_FOLDER}/$file + fi + done + COMMIT_CHANGES="yes" +else + echo -e "Current branch is [${CURRENT_BRANCH}]" + # http://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin + if [[ ",${WHITELISTED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then + echo -e "Branch [${CURRENT_BRANCH}] is whitelisted! Will copy the current docs to the [${CURRENT_BRANCH}] folder" + for f in docs/target/generated-docs/*; do + file=${f#docs/target/generated-docs/*} + if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then + # Not ignored... + # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html + if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then + # We don't want to copy the spring-cloud-sleuth.html + # we want it to be converted to index.html + cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html + git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html + else + cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} + git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file + fi + fi + done + COMMIT_CHANGES="yes" + else + echo -e "Branch [${CURRENT_BRANCH}] is not on the white list! Check out the Maven [${WHITELIST_PROPERTY}] property in + [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." + fi +fi -# Finally, switch back to the current branch and exit block -git checkout $branch +if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then + git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" + + # Uncomment the following push if you want to auto push to + # the gh-pages branch whenever you commit to master locally. + # This is a little extreme. Use with care! + ################################################################### + git push origin gh-pages +fi + +# Finally, switch back to the master branch and exit block +git checkout ${CURRENT_BRANCH} if [ "$dirty" != "0" ]; then git stash pop; fi -exit 0 +exit 0 \ No newline at end of file diff --git a/1.1.x/index.html b/1.1.x/index.html new file mode 100644 index 0000000..7c97a11 --- /dev/null +++ b/1.1.x/index.html @@ -0,0 +1,578 @@ + + + + + + + +Spring Boot Cloud CLI + + + + + +
+
+
+
+

Spring Boot CLI provides Spring Boot command line features for +Spring Cloud. You can write Groovy scripts to run Spring Cloud component applications +(e.g. @EnableEurekaServer). You can also easily do things like encryption and decryption to support Spring Cloud +Config clients with secret configuration values.

+
+
+ + + + + +
+
Note
+
+Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at github. +
+
+
+
+
+

Installation

+
+
+

To install, make +sure you have +Spring Boot CLI +(1.3.5 or better):

+
+
+
+
$ spring version
+Spring CLI v1.3.5.RELEASE
+
+
+
+

E.g. for SDKMan users

+
+
+
+
$ sdk install springboot 1.3.5.RELEASE
+$ sdk use springboot 1.3.5.RELEASE
+
+
+
+

and install the Spring Cloud plugin:

+
+
+
+
$ mvn install
+$ spring install org.springframework.cloud:spring-cloud-cli:1.1.2.RELEASE
+
+
+
+ + + + + +
+
Important
+
+Prerequisites: to use the encryption and decryption features +you need the full-strength JCE installed in your JVM (it’s not there by default). +You can download the "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files" +from Oracle, and follow instructions for installation (essentially replace the 2 policy files +in the JRE lib/security directory with the ones that you downloaded). +
+
+
+
+
+

Writing Groovy Scripts and Running Applications

+
+
+

Spring Cloud CLI has support for most of the Spring Cloud declarative +features, such as the @Enable* class of annotations. For example, +here is a fully functional Eureka server

+
+
+
app.groovy
+
+
@EnableEurekaServer
+class Eureka {}
+
+
+
+

which you can run from the command line like this

+
+
+
+
$ spring run app.groovy
+
+
+
+

To include additional dependencies, often it suffices just to add the +appropriate feature-enabling annotation, e.g. @EnableConfigServer, +@EnableOAuth2Sso or @EnableEurekaClient. To manually include a +dependency you can use a @Grab with the special "Spring Boot" short +style artifact co-ordinates, i.e. with just the artifact ID (no need +for group or version information), e.g. to set up a client app to +listen on AMQP for management events from the Spring CLoud Bus:

+
+
+
app.groovy
+
+
@Grab('spring-cloud-starter-bus-amqp')
+@RestController
+class Service {
+  @RequestMapping('/')
+  def home() { [message: 'Hello'] }
+}
+
+
+
+
+
+

Encryption and Decryption

+
+
+

The Spring Cloud CLI comes with an "encrypt" and a "decrypt" +command. Both accept arguments in the same form with a key specified +as a mandatory "--key", e.g.

+
+
+
+
$ spring encrypt mysecret --key foo
+682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
+$ spring decrypt --key foo 682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
+mysecret
+
+
+
+

To use a key in a file (e.g. an RSA public key for encyption) prepend +the key value with "@" and provide the file path, e.g.

+
+
+
+
$ spring encrypt mysecret --key @${HOME}/.ssh/id_rsa.pub
+AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+...
+
+
+
+
+
+ + + \ No newline at end of file