forked from SecureAuthCorp/saidp-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SecureAuthCorp:develop' into RAD-672
- Loading branch information
Showing
11 changed files
with
329 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: GitHub Actions | ||
run-name: ${{ github.ref_name }} GitHub Actions 🚀 | ||
on: [push, pull_request] | ||
jobs: | ||
Build-Publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository code ⬇️ | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 11 | ||
- name: Setup Gradle 🐘 | ||
uses: gradle/gradle-build-action@v2 | ||
- name: Make gradlew executable | ||
run: chmod +x ./gradlew | ||
- name: Run build with Gradle Wrapper 🏃 | ||
run: ./gradlew build -x test | ||
- name: Run tests 🧑⚕️ | ||
run: ./gradlew test | ||
# Might want to remove this step | ||
- name: Archive production artifacts ⬆️ | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Artifacts | ||
path: ./build/libs/saRestApi-*.jar | ||
- uses: jfrog/setup-jfrog-cli@v3 | ||
env: | ||
JF_URL: ${{ secrets.ARTIFACTORY_URL }} | ||
JF_USER: ${{ secrets.JFROG_USERNAME }} | ||
JF_PASSWORD: ${{ secrets.JFROG_PASSWORD }} | ||
- run: | | ||
# This command adds a new server configuration to the JFrog CLI | ||
- name: Create version for Artifactory | ||
run: | | ||
export BUILD_NAME="saidp-sdk-java" | ||
export BUILD_MODULE="sdk-java" | ||
export BUILD_NUMBER="1" | ||
export VERSION="1.0.3.5" | ||
jf rt upload "./build/libs/saRestApi-*.jar" radius-release-local/saRestApi/$PATH_TO_DIRECTORY --build-name $BUILD_NAME --build-number $BUILD_NUMBER --module $BUILD_MODULE | ||
# This action publishes the build information to Artifactory and deletes older builds | ||
- name: Publish to Artifactory | ||
run: | | ||
jf rt build-publish $BUILD_NAME $BUILD_NUMBER | ||
- run: echo "🍏 This job's status is ${{ job.status }}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#!/usr/bin/env groovy | ||
|
||
// load helpers | ||
library 'jenkins-pipeline-libs' | ||
|
||
node('radius-win-java11') { | ||
|
||
def gh_cid = scm.getUserRemoteConfigs()[0].getCredentialsId() | ||
def scmUrl = scm.getUserRemoteConfigs()[0].getUrl() | ||
boolean is_master = isMaster() | ||
|
||
properties([ | ||
|
||
// dont keep builds in Jenkins. | ||
buildDiscarder( logRotator(artifactDaysToKeepStr: '', | ||
artifactNumToKeepStr: '3', | ||
daysToKeepStr: '', | ||
numToKeepStr: '30') ), | ||
|
||
// set url for diff links to gh | ||
[ $class: 'GithubProjectProperty', | ||
displayName: '', | ||
projectUrlStr: "${getGitHubURL(scmUrl)}" ] | ||
]) | ||
|
||
try { | ||
stage('Checkout') { | ||
deleteDir() | ||
checkout scm | ||
} | ||
|
||
stage('Build') { | ||
def build_cmd = "call gradlew.bat --info --refresh-dependencies clean build" | ||
if (is_master) { | ||
currentBuild.displayName = "#${env.BUILD_NUMBER} - v${getVersion()}" | ||
} | ||
bat build_cmd | ||
} | ||
|
||
// invoke any steps specific to the master(release) branch | ||
stage('Tag & Push to Artifactory') { | ||
if (is_master) { | ||
// depends on GIT_USERNAME & GIT_PASSWORD env vars | ||
applyTag(gh_cid, "v${getVersion()}", scmUrl) | ||
} | ||
|
||
deployToArtifactory() | ||
} | ||
} | ||
catch (e) { | ||
// set status to failed | ||
currentBuild.result = "FAILED" | ||
|
||
// still need to throw so Jenkins will log error | ||
throw e | ||
} | ||
finally { | ||
stage('Archive, Clean & Notify') { | ||
def artifacts = 'build/libs/*.jar' | ||
def recipients = '#radius_notify' | ||
def status = currentBuild.result ?: 'SUCCESS' | ||
def msg = "${env.JOB_NAME} - <${env.BUILD_URL}|#${env.BUILD_NUMBER}" + | ||
(is_master ? " - v${getVersion()}" : "") + | ||
"> - ${status}\n\n${getChangeString()}" | ||
|
||
// save artifacts in Jenkins | ||
archiveArtifacts artifacts | ||
|
||
//send via library | ||
notifySlack { | ||
buildStatus = status | ||
channel = recipients | ||
message = msg | ||
} | ||
|
||
deleteDir() | ||
} | ||
} | ||
} | ||
|
||
// fetches version from file | ||
def getVersion(){ | ||
def matches = readFile('gradle.properties') =~ /currentVersion *= *["']?([0-9\.\-a-zA-Z]*)/ | ||
matches ? matches[0][1] : null | ||
} | ||
|
||
// fetch global gradle identifier for Jenkins | ||
// TODO move to global lib | ||
def getGradleId() { | ||
'gradle33' | ||
} | ||
|
||
boolean isMaster(){ | ||
("${env.BRANCH_NAME}" =~ /^(master|hotfix-.+)$/) | ||
} | ||
|
||
boolean isDevelop(){ | ||
("${env.BRANCH_NAME}" == "develop") | ||
} | ||
|
||
boolean isPR(){ | ||
("${env.BRANCH_NAME}" =~ /^(PR-[0-9]+)$/) | ||
} | ||
|
||
// deploys artifacts & build info to Artifactory | ||
//TODO - this and archive step should ref same files | ||
//TODO - use build retention to auto-delete old builds on develop only | ||
void deployToArtifactory(){ | ||
def server = Artifactory.server 'on-prem-artifactory' | ||
def gradle = Artifactory.newGradleBuild() | ||
|
||
def repo = "" | ||
if ( isMaster() ) { | ||
repo = "radius-release-local" | ||
} else if ( (isDevelop() || isPR()) && ( "${getVersion()}" =~ /^(.+SNAPSHOT)$/ ) ) { | ||
repo = "radius-snapshot-local" | ||
} else { | ||
// only deploy for master/hotfix/develop | ||
bat "echo Not a PR or Master, skipping deployment." | ||
return | ||
} | ||
|
||
// define where it will be deployed | ||
gradle.deployer server: server, repo: repo | ||
|
||
// if com.jfrog.artifactory plugin is already used in script | ||
//gradle.usesPlugin = true | ||
|
||
// use the wrapper and not the 'master' jenkins gradle. | ||
gradle.useWrapper = true | ||
|
||
//deploy maven descriptors | ||
gradle.deployer.deployMavenDescriptors = true | ||
|
||
//use gradle defined in main config | ||
gradle.tool = getGradleId() | ||
|
||
def build_info = gradle.run buildFile: 'build.gradle', tasks: 'clean artifactoryPublish' | ||
build_info.number = getVersion() | ||
|
||
def uploadSpec = """{ | ||
"files": [ | ||
{ | ||
"pattern": "build/libs/*.jar", | ||
"target": "${repo}/org/secureauth/sarestapi/saRestApi/${getVersion()}/" | ||
} | ||
] | ||
}""" | ||
|
||
server.publishBuildInfo(build_info) | ||
server.upload spec: uploadSpec, failNoOp: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
currentVersion=1.1.0.8 | ||
currentVersion=1.1.0.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.