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

New functionality by groovy-shared library #457

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.iml
.DS_Store
/.idea/
/target/
/work/
.vscode/launch.json
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"cSpell.words": [
"accmod",
"findbugs",
"Gitter",
"Gruetzmacher",
"hamcrest",
"instanceof",
"jenkinsci",
"kohsuke",
"lockableresources",
"Servlet"
]
}
86 changes: 4 additions & 82 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,10 @@

# Contributing

If you want to contribute to this plugin, you probably will need a Jenkins plugin development
environment. This basically means a current version of Java (Java 11 should probably be okay for now)
and [Apache Maven]. See the [Jenkins Plugin Tutorial] for details.
You could also go the [GitPod](https://gitpod.io/#https://github.com/jenkinsci/lockable-resources-plugin) way.
Any contributions are welcome.

If you have the proper environment, typing:
This repository contains lockable-resources [plugin](/plugin/) and [shared-library](/shared-library/README.md).

```sh
mvn verify
```
The [plugin](/plugin/) is the core part. Contains all the Java, Jelly, CSS, localizations ... for the plugin self.

should create a plugin as `target/*.hpi`, which you can install in your Jenkins instance. Running

```sh
mvn hpi:run
```

allows you to spin up a test Jenkins instance on [localhost] to test your
local changes before committing.

[Apache Maven]: https://maven.apache.org/
[Jenkins Plugin Tutorial]: https://jenkins.io/doc/developer/tutorial/prepare/
[localhost]: http://localhost:8080/jenkins/

## Code Style

This plugin tries to migrate to [Google Java Code Style], please try to adhere to that style
whenever adding new files or making big changes to existing files. If your IDE doesn't support
this style, you can use the [fmt-maven-plugin], like this:

```sh
mvn fmt:format -DfilesNamePattern=ChangedFile\.java
```

to reformat Java code in the proper style.

[Google Java Code Style]: https://google.github.io/styleguide/javaguide.html
[fmt-maven-plugin]: https://github.com/coveo/fmt-maven-plugin

## Code coverage

Test coverage is a percentage measure of the degree to which the source code of a program is executed when a test is run. A program with high test coverage has more of its source code executed during testing, which suggests it has a lower chance of containing undetected software bugs compared to a program with low test coverage. The best way to improve code coverage is writing of automated tests.

To get local line-by-line coverage report execute this command

```sh
mvn -P enable-jacoco clean verify jacoco:report
```

The report is then located in *target/site/jacoco/index.html*.

## License

The MIT License (MIT)

- Copyright 2013-2015 6WIND
- Copyright 2016-2018 Antonio Muñiz
- Copyright 2019 TobiX
- Copyright 2017-2022 Jim Klimov

See [LICENSE](LICENSE.txt)

## Localization

[![Crowdin](https://badges.crowdin.net/e/656dcffac5a09ad0fbdedcb430af1904/localized.svg)](https://jenkins.crowdin.com/lockable-resources-plugin)

Internationalization documentation for Jelly, Java and Groovy can be found [here](https://www.jenkins.io/doc/developer/internationalization/).

To translate this plugin we recommend to use [Crowdin](https://jenkins.crowdin.com/lockable-resources-plugin).

Read on [how to use the crowdin web interface](https://www.jenkins.io/doc/developer/crowdin/) to translate plugins.

When you want to help us, please create a new [feature request](https://github.com/jenkinsci/lockable-resources-plugin/issues/new?assignees=&labels=enhancement&template=2-feature-request.yml) with following content

Title:
l10n: \<language\>
Description
I would provide new (or update) translations for \<language\>

We will then add you to the Crowdin project.

For short translations / updates we can also send you invitation (time limited)

**Privacy policy notice**
When you start translating via Crowdin service, your browsers will send cookies to Crowdin so that Crowdin can identify translators contributing to the project. You might need to update the privacy policy to reflect this aspect of cookies usage.
The [shared-library](/shared-library/README.md) is an extension to the plugin self with many solutions and interfaces done in Groovy.
49 changes: 49 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,52 @@ buildPlugin(useContainerAgent: true, configurations: [
// see also https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/
[ platform: 'linux', jdk: '17', jenkins: '2.361.4' ],
])

def configs = [
[platform: 'linux', jdk: '11'],
[platform: 'windows', jdk: '11'],
[platform: 'linux', jdk: '17']
]

def stages = [failFast: true]

configs.each { c ->
final String stageIdentifier = "${c.platform}-${c.jdk}"
stages[stageIdentifier] = {
testSharedLib(c, stageIdentifier)
}
}

parallel(stages)

void testSharedLib(Map config, String stageIdentifier) {
String platform = config.platform
String jdk = config.jdk == null ? '11' : config.jdk
def timeoutValue = config.timeoutValue == null ? 120 : config.timeoutValue
String label = 'maven-' + jdk

if (platform == 'windows') {
label += '-windows'
}

timestamps() {

node(label) {
stage("Checkout (${stageIdentifier})") {
infra.checkoutSCM(null)
}

stage('Test shared lib') {
dir('shared-library') {
String cmd = 'mvn --no-transfer-progress -B clean verify'
if (isUnix()) {
sh cmd
} else {
bat cmd
}
junit(keepLongStdio: true, testResults: 'tests/target/surefire-reports/TEST-*.xml')
}
}
}
}
}
4 changes: 1 addition & 3 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ This steps need additional automation in release management. Therefore are comme
- [ ] For dependency updates, there are links to external changelogs and, if possible, full differentials.
- [ ] For new APIs and extension points, there is a link to at least one consumer.
- [ ] Any localizations are transferred to *.properties files.
- [ ] Changes in the interface are documented also as [examples](src/doc/examples/readme.md).
- [ ] Changes in the interface are documented also as [examples](plugin/doc/examples/readme.md), [groovy/examples](shared-library/doc/examples/readme.md).

### Maintainer checklist

Before the changes are marked as `ready-for-merge`:

- [ ] There is at least one (1) approval for the pull request and no outstanding requests for change.
- [ ] Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
- [ ] Changelog entries in the **pull request title** and/or **Proposed changelog entries** are accurate, human-readable, and in the imperative mood.
- [ ] Proper changelog labels are set so that the changelog can be generated automatically. See also [release-drafter-labels](https://github.com/jenkinsci/.github/blob/ce466227c534c42820a597cb8e9cac2f2334920a/.github/release-drafter.yml#L9-L50).
- [ ] If the change needs additional upgrade steps from users, the `upgrade-guide-needed` label is set and there is a **Proposed upgrade guidelines** section in the pull request title (see [example](https://github.com/jenkinsci/jenkins/pull/4387)).
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ lock(
echo 'Finish'
```

More examples are [here](src/doc/examples/readme.md).
More examples are [here](plugin/doc/examples/readme.md).

----

## Configuration as Code

This plugin can be configured via
Expand Down
6 changes: 6 additions & 0 deletions plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.iml
.DS_Store
/.idea/
/target/
/work/
.vscode/launch.json
77 changes: 77 additions & 0 deletions plugin/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

# Contributing

If you want to contribute to this plugin, you probably will need a Jenkins plugin development
environment. This basically means a current version of Java (Java 11 should probably be okay for now)
and [Apache Maven]. See the [Jenkins Plugin Tutorial] for details.
You could also go the [GitPod](https://gitpod.io/#https://github.com/jenkinsci/lockable-resources-plugin) way.

If you have the proper environment, typing:

```sh
mvn verify
```

should create a plugin as `target/*.hpi`, which you can install in your Jenkins instance. Running

```sh
mvn hpi:run
```

allows you to spin up a test Jenkins instance on [localhost] to test your
local changes before committing.

[Apache Maven]: https://maven.apache.org/
[Jenkins Plugin Tutorial]: https://jenkins.io/doc/developer/tutorial/prepare/
[localhost]: http://localhost:8080/jenkins/

## Code Style

This plugin tries to migrate to [Google Java Code Style], please try to adhere to that style
whenever adding new files or making big changes to existing files. If your IDE doesn't support
this style, you can use the [fmt-maven-plugin], like this:

```sh
mvn fmt:format -DfilesNamePattern=ChangedFile\.java
```

to reformat Java code in the proper style.

[Google Java Code Style]: https://google.github.io/styleguide/javaguide.html
[fmt-maven-plugin]: https://github.com/coveo/fmt-maven-plugin

## Code coverage

Test coverage is a percentage measure of the degree to which the source code of a program is executed when a test is run. A program with high test coverage has more of its source code executed during testing, which suggests it has a lower chance of containing undetected software bugs compared to a program with low test coverage. The best way to improve code coverage is writing of automated tests.

To get local line-by-line coverage report execute this command

```sh
mvn -P enable-jacoco clean verify jacoco:report
```

The report is then located in *target/site/jacoco/index.html*.

## Localization

[![Crowdin](https://badges.crowdin.net/e/656dcffac5a09ad0fbdedcb430af1904/localized.svg)](https://jenkins.crowdin.com/lockable-resources-plugin)

Internationalization documentation for Jelly, Java and Groovy can be found [here](https://www.jenkins.io/doc/developer/internationalization/).

To translate this plugin we recommend to use [Crowdin](https://jenkins.crowdin.com/lockable-resources-plugin).

Read on [how to use the crowdin web interface](https://www.jenkins.io/doc/developer/crowdin/) to translate plugins.

When you want to help us, please create a new [feature request](https://github.com/jenkinsci/lockable-resources-plugin/issues/new?assignees=&labels=enhancement&template=2-feature-request.yml) with following content

Title:
l10n: \<language\>
Description
I would provide new (or update) translations for \<language\>

We will then add you to the Crowdin project.

For short translations / updates we can also send you invitation (time limited)

**Privacy policy notice**
When you start translating via Crowdin service, your browsers will send cookies to Crowdin so that Crowdin can identify translators contributing to the project. You might need to update the privacy policy to reflect this aspect of cookies usage.
File renamed without changes.
File renamed without changes.
Loading