From: Anushka Bhandari Date: Mon, 2 Dec 2019 14:39:35 +0000 (+0530) Subject: Job to update docs configuration in docs and other odl projects X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=cf00c7646c042183f411384a585913b91993998f;p=releng%2Fbuilder.git Job to update docs configuration in docs and other odl projects These JJB Scripts completely automates the changes in config files of docs and other odl-projects. Change-Id: Ia056f3f11b83b527a650979989000f4feda10679 Signed-off-by: Anushka Bhandari --- diff --git a/jjb/docs/docs-macros.yaml b/jjb/docs/docs-macros.yaml new file mode 100644 index 000000000..0dd07a6e3 --- /dev/null +++ b/jjb/docs/docs-macros.yaml @@ -0,0 +1,8 @@ +--- +# Macros for the Docs project +- builder: + name: docs-update + builders: + - shell: !include-raw: + - docs_version_bump.sh + - docs_version_bump_projects.sh diff --git a/jjb/docs/docs-projects.yaml b/jjb/docs/docs-projects.yaml new file mode 100644 index 000000000..91204e2ca --- /dev/null +++ b/jjb/docs/docs-projects.yaml @@ -0,0 +1,20 @@ +--- +- project: + name: docs-update-{stream}-{project-name} + jobs: + - 'docs-update-{stream}-{project-name}' + stream: + - master: + branch: 'master' + project: docs + project-name: docs + - sodium: + branch: 'stable/sodium' + project: docs + project-name: docs + - sodium: + branch: 'stable/sodium' + project: releng/autorelease + project-name: autorelease + + build-node: centos7-builder-2c-2g diff --git a/jjb/docs/docs-template.yaml b/jjb/docs/docs-template.yaml new file mode 100644 index 000000000..13632e146 --- /dev/null +++ b/jjb/docs/docs-template.yaml @@ -0,0 +1,58 @@ +--- +# Autorelease build jobs +- job-template: + name: 'docs-update-{stream}-{project-name}' + + ###################### + # Default parameters # + ###################### + disable-job: 'false' + + ##################### + # Job Configuration # + ##################### + + project-type: freestyle + node: centos7-builder-2c-2g + disabled: '{disable-job}' + + properties: + - lf-infra-properties: + build-days-to-keep: 7 + + parameters: + - lf-infra-parameters: + project: '{project}' + project-name: '{project-name}' + branch: '{branch}' + stream: '{stream}' + lftools-version: '{lftools-version}' + - string: + name: RELEASE_NAME + description: 'The next release name eg Magnesium' + - bool: + name: PUBLISH + default: false + description: 'The flag to publish or not' + + scm: + - lf-infra-gerrit-scm: + git-url: '$GIT_URL/$GERRIT_PROJECT' + branch: '$GERRIT_BRANCH' + refspec: '$GERRIT_REFSPEC' + jenkins-ssh-credential: opendaylight-jenkins-ssh + submodule-disable: false + submodule-recursive: true + submodule-timeout: 10 + choosing-strategy: default + + wrappers: + - lf-infra-wrappers: + build-timeout: 10 + jenkins-ssh-credential: opendaylight-jenkins-ssh + + builders: + - docs-update + + publishers: + - lf-infra-publish diff --git a/jjb/docs/docs_version_bump.sh b/jjb/docs/docs_version_bump.sh new file mode 100644 index 000000000..9ed1bfe52 --- /dev/null +++ b/jjb/docs/docs_version_bump.sh @@ -0,0 +1,100 @@ +#!/bin/bash -l +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2019 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +update_file_usage () { + echo "Usage: $0 " + echo "" + echo " RELEASE_NAME: The RELEASE_NAME e.g Magnesium ." + echo " PUBLISH: Set to true to PUBLISH" + echo "" +} +while getopts :h: opts; do + case "$opts" in + h) + update_file_usage + exit 0 + ;; + [?]) + update_file_usage + exit 1 + ;; + esac +done +if [ "$GERRIT_PROJECT" == "docs" ]; then + RELEASE_NAME=$RELEASE_NAME + Next_release="$(tr '[:lower:]' '[:upper:]' <<< "${RELEASE_NAME:0:1}")${RELEASE_NAME:1}" # Captilize Version Name + release_name=$STREAM + Release_version="$(tr '[:lower:]' '[:upper:]' <<< "${release_name:0:1}")${release_name:1}" # Captilize Version Name + PUBLISH=$PUBLISH + stable_release_str=stable-$release_name + echo "Start Version Updating in docs project" + echo "RELEASE_NAME : $Next_release" + if [ "$GERRIT_BRANCH" == "master" ] + then + # #################################### + # # Changes in the master branch # + # #################################### + git checkout master + odl_release_str=odl-$release_name + next_odl_release_str=odl-$RELEASE_NAME + #change the odl- linking to stable- to odl- linking to latest + sed -i "s/$odl_release_str/$next_odl_release_str/g;" docs/conf.py + sed -i "s/$stable_release_str/latest/g;" docs/conf.py + + # Get the value of line with odl- linking to stable- + # for appending it to the line next to odl- linking to latest + line_number_nr=$(sed -n "/$next_odl_release_str/=" docs/conf.py) + pattern=$line_number_nr"p" + odl_latest="sed -n $pattern docs/conf.py" + odl_latest_line_value=$($odl_latest) + append_odl_latest=$(echo "$odl_latest_line_value" | sed "s/latest/$stable_release_str/g; s/$RELEASE_NAME/$release_name/g" ) + echo "Making changes in Master Branch" + # Update docs/conf.py + # sed -i "$line_number_nr'i'\ + # $append_odl_latest" docs/conf.py + sed -i "$line_number_nr a $append_odl_latest" docs/conf.py + # Updating version in docs/conf.yaml + sed -i "s/$Release_version/$Next_release/g" docs/conf.yaml + # Updating version in docs/javadoc.rst + sed -i "s/$release_name/$RELEASE_NAME/g" docs/javadoc.rst + if [ "$PUBLISH" == "true" ] + then + git add docs/conf.py docs/conf.yaml docs/javadoc.rst + echo "Update configuratiom files in master branch" + git commit -s -m "Update configuratiom files in master branch + + In docs/conf.py , add odl-$RELEASE_NAME pointing to latest + and change odl-$release_name to point to stable-$release_name. + In docs/conf.yaml + Change version from $Release_version to $Next_release. + In docs/javadoc.rst + Change links from $release_name to $RELEASE_NAME" + git review + fi + else + #################################### + # Changes in the new stable branch # + #################################### + echo "Making changes in $GERRIT_BRANCH" + + # #Updating links in docs/conf.py + sed -i "s/latest/$stable_release_str/g" docs/conf.py + if [ "$PUBLISH" == "true" ] + then + git add docs/conf.py + echo "Update docs/conf.py links from latest to $stable_release_str" + git commit -s -m "Update docs/conf.py links from latest to $stable_release_str + + Should be $stable_release_str on ${GERRIT_BRANCH}." + git review + fi + fi +fi \ No newline at end of file diff --git a/jjb/docs/docs_version_bump_projects.sh b/jjb/docs/docs_version_bump_projects.sh new file mode 100644 index 000000000..24d092292 --- /dev/null +++ b/jjb/docs/docs_version_bump_projects.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2019 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +update_file_usage () { + echo "Usage: $0 " + echo "" + echo " release_name: The release_name e.g Magnesium ." + echo " PUBLISH: Set to true to PUBLISH" + echo "" +} +while getopts :h: opts; do + case "$opts" in + h) + update_file_usage + exit 0 + ;; + [?]) + update_file_usage + exit 1 + ;; + esac +done +if [ "$GERRIT_PROJECT" == "releng/autorelease" ]; then + # User input + RELEASE_NAME=$RELEASE_NAME + # Captilize Version Name + release_name="$(tr '[:lower:]' '[:upper:]' <<< "${RELEASE_NAME:0:1}")${RELEASE_NAME:1}" + echo "Start Version Updating in odl-projects" + echo "RELEASE_NAME : $release_name" + ################ + # Start script # + ############### + + git submodule update + #'|| true' for repo like serviceutils where docs/conf.yaml doesn't exist + command='sed -i ''"s/.*version.*/version: '"$release_name"'/"'' docs/conf.yaml || true' + git submodule foreach "git checkout $STREAM" + git submodule foreach "$command" + if [ "$PUBLISH" == "true" ] + then + echo "Update docs header to $release_name in $STREAM" + git submodule foreach "git add . || true" + git submodule foreach "git commit -s -m 'Update docs header to $release_name in $STREAM + + Should be $release_name on $STREAM.' || true" + git submodule foreach "git review || true" + fi +fi \ No newline at end of file