Skip to content

Commit

Permalink
Merge pull request #67 from DontShaveTheYak/develop
Browse files Browse the repository at this point in the history
Release 0.7.0
  • Loading branch information
shadycuz authored May 21, 2021
2 parents 067816d + a94c978 commit 759e404
Show file tree
Hide file tree
Showing 27 changed files with 1,288 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v2.2.2

- name: Install dependencies
run: |
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/[email protected]

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v2.2.2

- name: Install dependencies
run: |
Expand All @@ -38,21 +38,12 @@ jobs:
uses: actions/[email protected]

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v2.2.2

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_PUSH_USERNAME }}
password: ${{ secrets.DOCKER_PUSH_TOKEN }}

- name: Test with pytest
env:
RUNNER_IMAGE: shadycuz/jenkins-std-lib
run: |
pytest
run: pytest
6 changes: 6 additions & 0 deletions .groovylintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"extends": "all",
"rules": {
"BlockEndsWithBlankLine": {
"enabled": false
},
"BlockStartsWithBlankLine": {
"enabled": false
},
"CompileStatic": {
"enabled": false
},
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ repos:
name: Groovy Lint
language: docker_image
entry: nvuillam/npm-groovy-lint
args: ['--failon', 'warning', '-l' , 'warning', '-p', 'src']
files: src/*
args: ['--failon', 'warning', '-l' , 'warning', '-f', '/src/src/**/*.groovy,/src/jobs/**/*.groovy']
files: .*\.groovy
pass_filenames: false
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Lint][lint-badge]][test-url]
[![Latest][doc-badge]][doc-url]

DontShaveTheYak presents the Jenkins Standard Library. A set of useful tools for everyday CI/CD jobs.
DontShaveTheYak presents the Jenkins Standard Library. A set of useful tools for every day CI/CD jobs.

Why use our library?
* [Less Yak Shaving](https://seths.blog/2005/03/dont_shave_that/) for your team.
Expand All @@ -27,7 +27,7 @@ For more detailed information see the offical Jenkins [Shared Library](https://w

### Recommended Setup

Our Shared Library will function and look its best if you setup the additional plugins below.
Our Shared Library will function and look its best if you setup the additional plugins below. We currently only support Agents that use Linux.

We recommend the following plugins:
* [simple-theme-plugin](https://plugins.jenkins.io/simple-theme-plugin/) - To remove non-useful information from build console. Use this config:
Expand All @@ -42,6 +42,8 @@ We recommend the following plugins:
```
* [AnsiColor](https://plugins.jenkins.io/ansicolor/) - To get color coded log messages from our logging package.

*Note: Individual library functions may have their own requirements. See the [docs][doc-url]*

### Usage

Once you have installed our shared library you just need to reference it at the top of any jobs.
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ version = project.findProperty('CICD_TAG') ?: '0.0.0-DEV'
group = 'io.github.dontshavetheyak'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
}


groovydoc {
use = true
source = sourceSets.main.groovy
Expand Down Expand Up @@ -122,7 +123,7 @@ repositories {
dependencies {
// Use the latest Groovy version for building this library
compileOnly('org.codehaus.groovy:groovy-all:3.0.8')
compileOnly('org.jenkins-ci.main:jenkins-core:2.291')
compileOnly('org.jenkins-ci.main:jenkins-core:2.292')
compileOnly('com.cloudbees:groovy-cps:1.32')
}

Expand Down
15 changes: 0 additions & 15 deletions docker/runner/Dockerfile

This file was deleted.

70 changes: 0 additions & 70 deletions docker/runner/init_scripts/PipelineLibrary.groovy

This file was deleted.

11 changes: 0 additions & 11 deletions docker/runner/init_scripts/System.groovy

This file was deleted.

23 changes: 0 additions & 23 deletions docker/runner/jenkins.yaml

This file was deleted.

80 changes: 80 additions & 0 deletions jobs/github/actions/step_example.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* groovylint-disable DuplicateMapLiteral, DuplicateStringLiteral, UnnecessaryParenthesesForMethodCallWithClosure, UnusedVariable */
@Library('pipeline-library')

import org.dsty.github.actions.Step

node() {

// This is needed if you run jenkins in a docker container.
// It's the path on the host machine where your docker bind mount is stored.
// docker run -v '/tmp/jenkins_home:/var/run/jenkins_home' jenkins/jenkins:lts
env.DIND_JENKINS_HOME = '/tmp/jenkins_home'

String cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)

Step action = new Step(this)

Map options

Map outputs

stage('Docker Action') {

options = [
'name': 'Test Docker Action',
'uses': 'actions/hello-world-docker-action@master',
'with': [
'who-to-greet': 'DockerAction'
]
]

outputs = action(options)

if (!outputs.time) {
error('Should have an output named time.')
}

}

stage('JavaScript Action') {

options = [
'name': 'Test JavaScript Action',
'uses': 'actions/hello-world-javascript-action@master',
'with': [
'who-to-greet': 'JavaScriptAction'
]
]

outputs = action(options)

if (!outputs.time) {
error('Should have an output named time.')
}

}

stage('Run Action') {

options = [
'name': 'Test RunAction.',
'run': '''\
echo "Setting an output!"
echo "::set-output name=test::SomeValue"
'''
]

outputs = action(options)

if (!outputs.test) {
error('Should have an output named test.')
}

if (outputs.test != 'SomeValue') {
error('Should set the correct output Value.')
}

}

cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)
}
39 changes: 39 additions & 0 deletions jobs/github/actions/tests/test_step.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* groovylint-disable DuplicateMapLiteral, DuplicateStringLiteral, Println, UnnecessaryParenthesesForMethodCallWithClosure, UnusedVariable */
@Library('pipeline-library')

import org.dsty.github.actions.Step

node() {

String cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)

Step action = new Step(this)

Map options = [
'name': 'TestIllegalArgument'
]

try {
Map outputs = action(options)
error("Should not run if 'uses' or 'run' not provided.")
} catch (IllegalArgumentException ex) {
println('Threw the correct exception.')
}

options = [
'name': 'TestConditional',
'uses': 'actions/hello-world-docker-action@master',
'with': [
'who-to-greet': 'Mona the Octocat'
],
'if': false
]

Map outputs = action(options)

if (outputs) {
error('Should haved skipped running the step.')
}

cps = sh(script: '#!/bin/bash\nset +x; > /dev/null 2>&1\necho Test for CPS issue', returnStdout: true)
}
Loading

0 comments on commit 759e404

Please sign in to comment.