-
Notifications
You must be signed in to change notification settings - Fork 6
Jenkins and Docker Support #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
prestoncraw
wants to merge
15
commits into
development
Choose a base branch
from
JenkinsDocker_Support
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+796
−1,207
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fffb5f9
remove legacy build files/config
prestoncraw 747f46f
Add initial implementation of new deploy workflow through jenkins
prestoncraw 75231d7
Cleanup semantics to match openHistorian scripts
prestoncraw 0a88d5f
Add initial dockerfile
prestoncraw 79b2e86
Fix casing
prestoncraw 8ebe4df
Fix casing
prestoncraw 893bce9
Add ability to skip authentication
prestoncraw cf0dcf3
update sln
prestoncraw fdc87d5
Add openSEE publish profiles and fix docker profiles
prestoncraw 9278648
remove unused script
prestoncraw d9473c4
Add ui versioning
prestoncraw eca9868
remove release script
prestoncraw e2c1911
Fix copyright
prestoncraw 66973b4
Address comments
prestoncraw 9e8fd1f
address comments
prestoncraw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,266 @@ | ||
| import hudson.model.Result | ||
| import jenkins.model.CauseOfInterruption | ||
| import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException | ||
|
|
||
| def haltBuildWithSuccess() { | ||
| currentBuild.rawBuild.@result = Result.SUCCESS | ||
| def cause = new CauseOfInterruption.UserInterruption("Build halted programmatically with SUCCESS status") | ||
| throw new FlowInterruptedException(Result.SUCCESS, false, cause) | ||
| } | ||
|
|
||
| pipeline { | ||
| agent any | ||
|
|
||
| environment { | ||
| github_pat = credentials('github-pat') | ||
| devBranch = "development" | ||
| mainBranch = "master" | ||
| NUGET_PACKAGES = "D:\\NuGetCache" | ||
| } | ||
|
|
||
| stages { | ||
| stage('Prepare Environment') { | ||
| steps { | ||
| script { | ||
| // Set current Version | ||
| def fileContent = powershell(returnStdout: true, script: ''' | ||
| Get-Content -Path "./scripts/OpenSEE.version" -Raw | ||
| ''').trim() | ||
| env.openSEEVersion = fileContent | ||
| println("openSEE version: ${env.openSEEVersion}") | ||
| } | ||
| script { | ||
| //Set current Commit | ||
| env.GIT_COMMIT = bat(script: '@git rev-parse HEAD', returnStdout: true).trim() | ||
| println("Current Git Commit: ${env.GIT_COMMIT}") | ||
| } | ||
| script { | ||
| //Get last release from git tags | ||
| bat( script: "@git fetch origin ${env.mainBranch}:refs/remotes/origin/${env.mainBranch}") | ||
| def mainCommit = bat(script: "@git rev-parse origin/${env.mainBranch}", returnStdout: true).trim() | ||
| try { | ||
| env.LAST_RELEASE_TAG = bat(script: "@git describe --tags --abbrev=0 ${mainCommit}", returnStdout: true).trim() | ||
| } | ||
| catch (Exception ex) { | ||
| println("No tags found, setting LAST_RELEASE_TAG to v2.0.0") | ||
| env.LAST_RELEASE_TAG = "v2.0.0" | ||
| } | ||
| println("Last Release Tag: ${env.LAST_RELEASE_TAG}") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Check Conditions') { | ||
| when { | ||
| anyOf { | ||
| not { | ||
| anyOf { | ||
| expression { env.BRANCH_NAME.startsWith("PR") } | ||
| expression { env.BRANCH_NAME == "${env.mainBranch}" } | ||
| } | ||
| } | ||
| allOf { | ||
| expression { env.BRANCH_NAME.startsWith("PR") } | ||
| expression { env.CHANGE_BRANCH != "${env.devBranch}" } | ||
| } | ||
| allOf { | ||
| expression { env.BRANCH_NAME.startsWith("PR") } | ||
| expression { env.CHANGE_TARGET != "${env.mainBranch}" } | ||
| } | ||
| } | ||
| } | ||
| steps { | ||
| haltBuildWithSuccess() | ||
| } | ||
| } | ||
|
|
||
| stage('Checkout Master Branch') { | ||
| when { | ||
| expression { | ||
| return env.BRANCH_NAME == "${env.mainBranch}" | ||
| } | ||
| } | ||
| steps { | ||
| script { | ||
| bat(script: "@git fetch origin ${env.BRANCH_NAME}:refs/remotes/origin/${env.BRANCH_NAME}") | ||
| bat(script: "@git checkout origin/${env.BRANCH_NAME}") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Checkout Development Branch') { | ||
| when { | ||
| expression { | ||
| return env.CHANGE_BRANCH == "${env.devBranch}" | ||
| } | ||
| } | ||
| steps { | ||
| script { | ||
| bat(script: "@git fetch origin ${env.CHANGE_BRANCH}:refs/remotes/origin/${env.CHANGE_BRANCH}") | ||
| bat(script: "@git checkout origin/${env.CHANGE_BRANCH}") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Application Version') { | ||
| when { | ||
| expression { | ||
| return env.BRANCH_NAME != "${env.mainBranch}" | ||
| } | ||
| } | ||
| steps { | ||
| script { | ||
| env.GIT_COMMIT = bat(script: '@git rev-parse HEAD', returnStdout: true).trim() | ||
| } | ||
| powershell "powershell.exe -File .\\scripts\\Versioning.ps1 -VersionFile './scripts/OpenSEE.version' -Commit false" | ||
| bat(script: "@git add scripts/OpenSEE.version") | ||
| bat(script: "git diff --cached --quiet || git commit -m \"Updated Version Number\"") | ||
| } | ||
| } | ||
|
|
||
| stage('Gemstone Updates') { | ||
| when { | ||
| expression { | ||
| return env.BRANCH_NAME != "${env.mainBranch}" | ||
| } | ||
| } | ||
| steps { | ||
| powershell "powershell.exe -File .\\scripts\\GemstoneUpdates.ps1 -VersionFile './src/Directory.Build.props'" | ||
| powershell "powershell.exe -File .\\scripts\\CreateDependencyPR.ps1 -GithubToken '${github_pat}' -DevelopmentBranchName '${devBranch}'" | ||
| script { | ||
| bat(script: "@git add src/Directory.Build.props") | ||
| bat(script: "git diff --cached --quiet || git commit -m \"Updated Dependencies\"") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Push Changes') { | ||
| when { | ||
| allOf { | ||
| expression { | ||
| return env.BRANCH_NAME != "${env.mainBranch}" | ||
| } | ||
| expression { | ||
| return bat(script: '@git rev-parse HEAD', returnStdout: true).trim() != env.GIT_COMMIT | ||
| } | ||
| } | ||
| } | ||
| steps { | ||
| powershell "git push origin HEAD:${env.devBranch}" | ||
| haltBuildWithSuccess() | ||
| } | ||
| } | ||
|
|
||
| stage('Build Production UI') { | ||
| steps { | ||
| dir('src/OpenSEE') { | ||
| bat(script: 'npm run build') | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Build Docker Images') { | ||
| when { | ||
| anyOf { | ||
| expression { | ||
| return env.CHANGE_BRANCH == "${env.devBranch}" | ||
| } | ||
| expression { | ||
| return env.BRANCH_NAME == "${env.mainBranch}" | ||
| } | ||
| } | ||
| } | ||
| steps { | ||
| script { | ||
| env.openSEEDockerTag = env.CHANGE_BRANCH == "${env.devBranch}" ? "${env.openSEEVersion}a" : env.openSEEVersion | ||
| println("Building openSEE Docker image tag: opensee:${env.openSEEDockerTag}") | ||
| } | ||
|
|
||
| powershell "msbuild /t:Publish /p:DeployOnBuild=true';'Configuration=Release';'PublishProfile='Docker Release Profile openSEE' './src/OpenSEE/OpenSEE.csproj' /nodeReuse:false -restore" | ||
| powershell "docker build --build-arg CONFIGURATION=Release -f .\\openSEE.dockerfile -t opensee:${env.openSEEDockerTag} ." | ||
| } | ||
| } | ||
|
|
||
| stage('Publish Application') { | ||
| steps { | ||
| powershell """ | ||
| dotnet publish '.\\src\\OpenSEE\\OpenSEE.csproj' ` | ||
| '-p:PublishProfile=Release Profile openSEE' | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| stage('Package Application') { | ||
| steps { | ||
| script { | ||
| if (!env.WEBHOST_DELIVERY_DIRECTORY?.trim()) { | ||
| error('WEBHOST_DELIVERY_DIRECTORY is not configured in Jenkins.') | ||
| } | ||
|
|
||
| env.archiveName = env.BRANCH_NAME == "${env.mainBranch}" ? | ||
| "openSEE_v${env.openSEEVersion}.zip" : | ||
| "openSEE_v${env.openSEEVersion}a.zip" | ||
| } | ||
| powershell """ | ||
| [xml]\$publishProfile = Get-Content ` | ||
| -LiteralPath '.\\src\\OpenSEE\\Properties\\PublishProfiles\\Release Profile openSEE.pubxml' ` | ||
| -Raw | ||
| \$publishDir = (\$publishProfile.Project.PropertyGroup | | ||
| Where-Object { \$_.PublishDir }).PublishDir | ||
|
|
||
| Compress-Archive ` | ||
| -Path (Join-Path '.\\src\\OpenSEE' "\$publishDir*") ` | ||
| -DestinationPath '${WORKSPACE}\\${env.archiveName}' ` | ||
| -Force | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| stage('Comment Prerelease') { | ||
| when { | ||
| expression { | ||
| return env.CHANGE_BRANCH == "${env.devBranch}" | ||
| } | ||
| } | ||
| steps { | ||
| powershell """ | ||
| powershell.exe -File .\\scripts\\GithubComment.ps1 ` | ||
| -Comment 'Prerelease openSEE v${env.openSEEVersion}a is available.' ` | ||
| -BranchName '${env.devBranch}' ` | ||
| -GithubToken '${github_pat}' ` | ||
| -RepoOwner 'GridProtectionAlliance' ` | ||
| -RepoName 'openSEE' | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| stage('Deploy Prerelease') { | ||
| when { | ||
| expression { | ||
| return env.CHANGE_BRANCH == "${env.devBranch}" | ||
| } | ||
| } | ||
| steps { | ||
| powershell "Move-Item -Path '${WORKSPACE}\\${env.archiveName}' -Destination '${env.WEBHOST_DELIVERY_DIRECTORY}\\openSEE\\PreRelease\\${env.archiveName}' -Force" | ||
| } | ||
| } | ||
|
|
||
| stage('Deploy Release') { | ||
| when { | ||
| allOf { | ||
| expression { | ||
| return env.BRANCH_NAME == "${env.mainBranch}" | ||
| } | ||
| expression { | ||
| return env.openSEEVersion != env.LAST_RELEASE_TAG | ||
| } | ||
| } | ||
| } | ||
| steps { | ||
| powershell "Move-Item -Path '${WORKSPACE}\\${env.archiveName}' -Destination '${env.WEBHOST_DELIVERY_DIRECTORY}\\openSEE\\${env.archiveName}' -Force" | ||
| powershell "git tag -a v${env.openSEEVersion} -m 'Version ${env.openSEEVersion} release'" | ||
| powershell "git push origin --tags" | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,21 @@ | ||
| # Use the official .NET 9.0 runtime as the base image | ||
| FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base | ||
| ARG CONFIGURATION="Development" | ||
|
|
||
| # Set the working directory inside the container | ||
| WORKDIR /openSEE | ||
|
|
||
| # Copy openSEE from the local published folder to the container | ||
| COPY ./[Bb]uild/${CONFIGURATION}/Applications/openSEE/net9.0/publish/linux-x64/ /openSEE/ | ||
|
|
||
| # Set permissions for all copied folders and files | ||
| RUN chmod -R 777 /openSEE | ||
|
|
||
| # Ensure the application is executable | ||
| RUN chmod +x /openSEE/OpenSEE | ||
|
|
||
| # Expose the webserver port | ||
| EXPOSE 8080 | ||
|
|
||
| # Define the entry point to run | ||
| ENTRYPOINT ["sh", "-c", "exec /openSEE/OpenSEE"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very different from the other apps.
Is there a reason we can't just use a Publish Profile?