You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Antonio Vieiro (JIRA)" <ji...@apache.org> on 2018/04/09 10:12:00 UTC

[jira] [Closed] (NETBEANS-522) Jenkins task to publish netbeans.apache.org website

     [ https://issues.apache.org/jira/browse/NETBEANS-522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Vieiro closed NETBEANS-522.
-----------------------------------
    Resolution: Fixed

h1. A Jenkins job to build netbeans.apache.org

h2. The master branch

* The master branch is hosted at github: [https://github.com/apache/incubator-netbeans-website]
* It contains some scritps with [http://jbake.org] a static site generator.
* It contains some asciidoc files with the source content.
* When the script is run, it generates HTML in the directory netbeans.apache.org/build/jbake
* Apache Infra added a "webhook" script in git that fires the jenkins job whenever something is changed in "master".

h2. The asf-site branch:

* The asf-site branch is checked out from gitbox: [https://gitbox.apache.org/repos/asf/incubator-netbeans-website.git]
* We need to use the gitbox repository because we have to commit & push generated HTML there.
* This branch is configured so that new commits are automatically published to [http://netbeans.apache.org].

h2. The jenkins job:

* The jenkins job is at [https://builds.apache.org/view/Incubator%20Projects/job/incubator-netbeans-website/]
* This job is fired whenever something is changed in github (because we have a webhook trigger set up in github): the "trigger" is of type "GitHub hook trigger for GITScm polling".

The operation of the job is a shell script that:

* It firsts clones the "master" branch from github (a shallow clone is enough to generate HTML content).
* Then checks out the "asf-site" branch from gitbox.
* Runs the static site generator, that generates HTML in netbeans.apache.org/build/jbake
* Copies the generated HTML into "asf-site"/content.
* Commits and pushes the "asf-site" branch to gitbox, using the "jenkins (master pub key)" key already available for jenkins jobs.

The script is:

{code:bash}

#!/usr/bin/env bash

#
# Infra has set up a webhook at the github repo that fires this task. 
# We cannot push to github, though, but only to gitbox.
# So we need two repositories in two directories:
#
# master-branch (just cloning):
# git clone https://github.com/apache/incubator-netbeans-website.git master-branch
# asf-site-branch (pushing):
# git clone https://gitbox.apache.org/repos/asf/incubator-netbeans-website.git asf-site-branch

#
# Testing:
#
echo "CHANGE_ID -${CHANGE_ID}-"
echo "CHANGE_URL -${CHANGE_URL}-"
echo "BRANCH_NAME -${BRANCH_NAME}-"
echo "GIT_COMMIT -${GIT_COMMIT}-"
echo "GIT_PREVIOUS_COMMIT -${GIT_PREVIOUS_COMMIT}-"

if [ "X${GIT_COMMIT}" = "X${GIT_PREVIOUS_COMMIT}" ]; then
	echo "Commit ${GIT_COMMIT} equal to previous commit ${GIT_PREVIOUS_COMMIT}: we are done"
    exit 0
fi


#
# Run the gradlew script to generate HTML for netbeans.apache.org
#

chmod u+x master-branch/netbeans.apache.org/gradlew
cd master-branch/netbeans.apache.org
echo "Building site..."
./gradlew buildSite
if [ $? -ne 0 ]; then
	echo "Build failed!"
    exit 1
fi
cd ../..

#
# Copy the generated html to the asf-site branch
#
cd asf-site-branch
git checkout asf-site
git fetch origin asf-site
git pull origin asf-site
rm -rf content/*
cp -R ../master-branch/netbeans.apache.org/build/bake/* content
cp ../master-branch/netbeans.apache.org/build/bake/.htaccess content
cp ../master-branch/netbeans.apache.org/build/bake/wiki/.htaccess content/wiki

#
# Commit and push to gitbox 
#
echo "Adding content..."
git add -v content/
echo "Commit to gitbox..."
git status

#
# Note: the "Automated site publishing" text below is used to reject
# builds triggered when pushing to asf-site (see git configuration above).
# If you change this text then remember to change it above also.
#
git commit -v -m "Automated site publishing by Jenkins build ${BUILD_NUMBER}"
if [ $? -ne 0 ]; then
    echo "Commit failed."
    exit 2
fi
echo "Pushing to gitbox..."
git push -v origin asf-site
if [ $? -ne 0 ]; then
    echo "Push failed."
    exit 3
fi
echo "Done."

{code}


For questions or more information please contact vieiro@apache.org





> Jenkins task to publish netbeans.apache.org website
> ---------------------------------------------------
>
>                 Key: NETBEANS-522
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-522
>             Project: NetBeans
>          Issue Type: Task
>          Components: website
>            Reporter: Antonio Vieiro
>            Assignee: Antonio Vieiro
>            Priority: Major
>              Labels: jenkins, website
>
> Set up a jenkins task to update the https://netbeans.apache.org website
> See https://issues.apache.org/jira/browse/INFRA-16157 for the original request to INFRA.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists