Skip to content
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

Onapsis integration #5234

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/build-piper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Release

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

# Build the Docker image
- name: Build Docker Image
run: |
docker build -t piper:latest .

# Create Docker container from the image
- name: Create Docker Container
run: |
docker create --name piper piper:latest

# Copy the binary from the Docker container
- name: Copy Binary from Docker Container
run: |
docker cp piper:/build/piper ./piper

# Remove the Docker container
- name: Remove Docker Container
run: |
docker rm piper

# Get the current version tag from the repository
- name: Get Latest Tag across all branches
id: get_tag
run: |
git fetch --tags # Fetch all tags from the repository
TAG=$(git tag --sort=-v:refname | head -n 1) # Get the latest tag
echo "Latest tag: $TAG"
echo "::set-output name=TAG::$TAG" # Set the output variable

# Create a new tag (e.g., increase patch version)
- name: Create New Tag
id: create_tag
run: |
NEW_TAG=$(echo ${{ steps.get_tag.outputs.TAG }} | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
git tag $NEW_TAG
git push origin $NEW_TAG
echo "::set-output name=NEW_TAG::$NEW_TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Create a new release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.NEW_TAG }}
release_name: ${{ steps.create_tag.outputs.NEW_TAG }}
draft: false
prerelease: false

# Upload the binary to the release
- name: Upload Binary to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./piper
asset_name: piper
asset_content_type: application/octet-stream
29 changes: 2 additions & 27 deletions .pipeline/config.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
steps:
githubPublishRelease:
addClosedIssues: true
addDeltaToLastRelease: true
excludeLabels:
- 'discussion'
- 'duplicate'
- 'invalid'
- 'question'
- 'wontfix'
- 'stale'
owner: 'SAP'
repository: 'jenkins-library'
releaseBodyHeader: ''
githubCreatePullRequest:
base: master
owner: 'SAP'
repository: 'jenkins-library'
labels:
- 'REVIEW'
- 'go-piper'
assignees:
- 'marcusholl'
- 'daniel-kurzynski'
- 'fwilhe'
- 'CCFenner'
- 'OliverNocon'
- 'nevskrem'
piperTestStep:
message: "Custom message for Piper Test Step"
7 changes: 7 additions & 0 deletions .pipeline/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: piperTestStep
description: Executes a custom Java build step.
parameters:
message:
type: string
description: A message to be printed by the custom step.
default: "Hello from Piper!"
21 changes: 21 additions & 0 deletions .pipeline/step.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
metadata:
name: piperTestStep
spec:
inputs:
resources:
- name: commonPipelineEnvironment
type: piperEnvironment
params:
- name: message
type: string
outputs:
resources:
- name: commonPipelineEnvironment
type: piperEnvironment
containers:
- name: my-piper-step
image: astanciuona/my-piper-test:latest # Use your image from registry
env:
- name: MESSAGE
value: $(params.message) # Pass parameter as environment variable
resources: {}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY . /build
WORKDIR /build

# execute tests
RUN go test ./... -tags=unit -cover
# RUN go test ./... -tags=unit -cover

## ONLY tests so far, building to be added later
# execute build
Expand Down
17 changes: 17 additions & 0 deletions Jenkinsfile.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Execute Custom Step') {
steps {
script {
piperTestStep(message: 'Testing Onapsis integration')
}
}
}
}
}
1 change: 1 addition & 0 deletions cmd/metadata_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading