From a473e4828e9255664346a3649451fcb5612b422b Mon Sep 17 00:00:00 2001 From: Garlapati Anil Masthan Setty Date: Mon, 18 Nov 2024 19:00:36 +0530 Subject: [PATCH] Added support for Groovy 3 version and Added github workflows for CI & CD and Modified readme file --- .github/workflows/gradle-cd.yml | 65 +++++++++++++++++ .github/workflows/gradle-ci.yml | 34 +++++++++ README.md | 4 +- .../air/plugin/tool/AirPluginTool.groovy | 69 +++++++++++++++++++ src/main/zip/apt.groovy | 6 +- src/main/zip/apt_key.groovy | 6 +- src/main/zip/ashell.groovy | 6 +- src/main/zip/command.groovy | 6 +- src/main/zip/copy.groovy | 6 +- src/main/zip/file.groovy | 6 +- .../zip/getBuiltinAnsibleProperties.groovy | 6 +- src/main/zip/get_url.groovy | 6 +- src/main/zip/info.xml | 3 + src/main/zip/lineinfile.groovy | 6 +- src/main/zip/pip.groovy | 6 +- src/main/zip/plugin.xml | 2 +- src/main/zip/service.groovy | 6 +- src/main/zip/shell.groovy | 6 +- src/main/zip/unarchive.groovy | 6 +- src/main/zip/upgrade.xml | 2 + 20 files changed, 203 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/gradle-cd.yml create mode 100644 .github/workflows/gradle-ci.yml create mode 100644 src/main/groovy/com/urbancode/air/plugin/tool/AirPluginTool.groovy diff --git a/.github/workflows/gradle-cd.yml b/.github/workflows/gradle-cd.yml new file mode 100644 index 0000000..cc50396 --- /dev/null +++ b/.github/workflows/gradle-cd.yml @@ -0,0 +1,65 @@ +name: Gradle CD + +on: + push: + branches: [ "master" ] + +jobs: + + create-release: + + permissions: write-all + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'adopt-openj9' + + - name: Set up Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Fetch all tags + run: git fetch --tags + + - name: Determine next tag version + id: getNextTag + run: | + # Get version from plugin.xml + pluginXmlVersion=$(grep -oP '> $GITHUB_OUTPUT + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: Create dist + run: ./gradlew "-PpluginVersion=${{ steps.getNextTag.outputs.value }}" distPlugin + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.getNextTag.outputs.value }} + files: "build/distributions/*.zip" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/gradle-ci.yml b/.github/workflows/gradle-ci.yml new file mode 100644 index 0000000..b78dcff --- /dev/null +++ b/.github/workflows/gradle-ci.yml @@ -0,0 +1,34 @@ +name: Build Gradle Project + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build-gradle-project: + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'adopt-openj9' + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: Run build + run: ./gradlew build + + - name: Run tests + run: ./gradlew test \ No newline at end of file diff --git a/README.md b/README.md index ca50d7e..e1ca500 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ This plugin is protected under the [Eclipse Public 1.0 License](http://www.eclip The packaged zip is located in the releases folder. No special steps are required for installation. See Installing plug-ins in UrbanCode Deploy. Download this zip file if you wish to skip the manual build step. Otherwise, download the entire Ansible-Toolkit-UCD project and run the `gradle` command in the top level folder. This should compile the code and create a new distributable zip within the `build/distributions` folder. Use this command if you wish to make your own changes to the plugin. ### History + Version 54 + - Added support for Groovy 3 version Version 53 - The Ansible Toolkit is now built through Gradle. All Ant and Ivy build pieces have been removed. Version 52 @@ -21,5 +23,5 @@ This plugin is protected under the [Eclipse Public 1.0 License](http://www.eclip ### How to build the plugin from command line: 1. Navigate to the base folder of the project through command line. -2. Make sure that there is a build.gradle file in the root directory and execute the 'gradle' command. +2. Make sure that there is a build.gradle file in the root directory and execute the 'gradlew' command. 3. The built plugin is located at `build/distributions/Ansible-Toolkit-UCD-vdev.zip` diff --git a/src/main/groovy/com/urbancode/air/plugin/tool/AirPluginTool.groovy b/src/main/groovy/com/urbancode/air/plugin/tool/AirPluginTool.groovy new file mode 100644 index 0000000..fecb925 --- /dev/null +++ b/src/main/groovy/com/urbancode/air/plugin/tool/AirPluginTool.groovy @@ -0,0 +1,69 @@ +/** + * © Copyright IBM Corporation 2016, 2024. + * This is licensed under the following license. + * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) + * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. + */ +package com.urbancode.air.plugin.tool + +class AirPluginTool { + + //************************************************************************** + // CLASS + //************************************************************************** + //************************************************************************** + // INSTANCE + //************************************************************************** + final public def isWindows = (System.getProperty('os.name') =~ /(?i)windows/).find() + def out = System.out; + def err = System.err; + private def inPropsFile; + private def outPropsFile; + def outProps; + public AirPluginTool(def inFile, def outFile){ + inPropsFile = inFile; + outPropsFile = outFile; + outProps = new Properties(); + } + public Properties getStepProperties() { + def props = new Properties(); + def inputPropsFile = this.inPropsFile; + def inputPropsStream = null; + try { + inputPropsStream = new FileInputStream(inputPropsFile); + props.load(inputPropsStream); + } + catch (IOException e) { + throw new RuntimeException(e); + } + finally { + inputPropsStream.close(); + } + return props; + } + public void setOutputProperty(String name, String value) { + this.outProps.setProperty(name, value); + } + public void setOutputProperties() { + OutputStream outputPropsStream = null; + try { + outputPropsStream = new FileOutputStream(this.outPropsFile); + outProps.store(outputPropsStream, ""); + } + finally { + if (outputPropsStream != null) { + outputPropsStream.close(); + } + } + } + public String getAuthToken() { + String authToken = System.getenv("AUTH_TOKEN"); + return "{\"token\" : \"" + authToken + "\"}"; + } + public String getAuthTokenUsername() { + return "PasswordIsAuthToken"; + } + public void storeOutputProperties() { + setOutputProperties(); + } +} diff --git a/src/main/zip/apt.groovy b/src/main/zip/apt.groovy index 09d4813..253671b 100644 --- a/src/main/zip/apt.groovy +++ b/src/main/zip/apt.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/apt_key.groovy b/src/main/zip/apt_key.groovy index 58e771a..cb40820 100644 --- a/src/main/zip/apt_key.groovy +++ b/src/main/zip/apt_key.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/ashell.groovy b/src/main/zip/ashell.groovy index fd942d4..025451a 100644 --- a/src/main/zip/ashell.groovy +++ b/src/main/zip/ashell.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/command.groovy b/src/main/zip/command.groovy index 3fbb772..516ac60 100644 --- a/src/main/zip/command.groovy +++ b/src/main/zip/command.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/copy.groovy b/src/main/zip/copy.groovy index c0b1da4..1128412 100644 --- a/src/main/zip/copy.groovy +++ b/src/main/zip/copy.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/file.groovy b/src/main/zip/file.groovy index 8ae0e9b..2b17bb7 100644 --- a/src/main/zip/file.groovy +++ b/src/main/zip/file.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/getBuiltinAnsibleProperties.groovy b/src/main/zip/getBuiltinAnsibleProperties.groovy index 0a5fae1..c3c0050 100644 --- a/src/main/zip/getBuiltinAnsibleProperties.groovy +++ b/src/main/zip/getBuiltinAnsibleProperties.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/get_url.groovy b/src/main/zip/get_url.groovy index da6038e..3facb6d 100644 --- a/src/main/zip/get_url.groovy +++ b/src/main/zip/get_url.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/info.xml b/src/main/zip/info.xml index 4bf9fc8..5116522 100644 --- a/src/main/zip/info.xml +++ b/src/main/zip/info.xml @@ -137,5 +137,8 @@ The Ansible Toolkit is now built through Gradle. All Ant and Ivy build pieces have been removed. + + Added support for Groovy 3 version + diff --git a/src/main/zip/lineinfile.groovy b/src/main/zip/lineinfile.groovy index cd8cec5..f9537e7 100644 --- a/src/main/zip/lineinfile.groovy +++ b/src/main/zip/lineinfile.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/pip.groovy b/src/main/zip/pip.groovy index 5e297da..e684d5d 100644 --- a/src/main/zip/pip.groovy +++ b/src/main/zip/pip.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/plugin.xml b/src/main/zip/plugin.xml index bfa0fd8..bc0cf67 100644 --- a/src/main/zip/plugin.xml +++ b/src/main/zip/plugin.xml @@ -8,7 +8,7 @@
- + This plug-in includes steps that integrate with Ansible. diff --git a/src/main/zip/service.groovy b/src/main/zip/service.groovy index 0853373..7c006a0 100644 --- a/src/main/zip/service.groovy +++ b/src/main/zip/service.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/shell.groovy b/src/main/zip/shell.groovy index 08de43c..5e06083 100644 --- a/src/main/zip/shell.groovy +++ b/src/main/zip/shell.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/unarchive.groovy b/src/main/zip/unarchive.groovy index ad86a2c..b4372ea 100644 --- a/src/main/zip/unarchive.groovy +++ b/src/main/zip/unarchive.groovy @@ -1,12 +1,10 @@ +import com.urbancode.air.plugin.tool.AirPluginTool /** - * © Copyright IBM Corporation 2016, 2017. + * © Copyright IBM Corporation 2016, 2024. * This is licensed under the following license. * The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html) * U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ - -import com.urbancode.air.AirPluginTool; - def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file def props = apTool.getStepProperties(); diff --git a/src/main/zip/upgrade.xml b/src/main/zip/upgrade.xml index aab40dc..44fad22 100644 --- a/src/main/zip/upgrade.xml +++ b/src/main/zip/upgrade.xml @@ -27,4 +27,6 @@ + +