Skip to content

Commit

Permalink
Clean up CLI (#448)
Browse files Browse the repository at this point in the history
Co-authored-by: James Nord <jtnord@users.noreply.github.com>
  • Loading branch information
basil and jtnord committed Feb 14, 2023
1 parent 6da964d commit b0641fa
Show file tree
Hide file tree
Showing 16 changed files with 369 additions and 638 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ print-java-home:
.PHONY: demo
demo: target/plugins-compat-tester-cli.jar $(WAR_PATH) print-java-home
java -jar target/plugins-compat-tester-cli.jar \
-workDirectory $(CURDIR)/work \
-mvn $(MVN_EXECUTABLE) \
-war $(CURDIR)/$(WAR_PATH) \
-includePlugins $(PLUGIN_NAME) \
--working-dir $(CURDIR)/work \
--mvn $(MVN_EXECUTABLE) \
--war $(CURDIR)/$(WAR_PATH) \
--include-plugins $(PLUGIN_NAME) \
$(EXTRA_OPTS)

# We do not automatically rebuild Docker here
Expand Down
24 changes: 6 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ The PCT cli supports to pass a war file containing plugins (generated with Custo
the plugins is infered from the war file contents.

In such scenarios is tipical to want to run the PCT for all plugins contained in the war file, to avoid having to spawn a new docker container for each plugin
you can use the env variables `DO_NOT_OVERRIDE_PCT_CHECKOUT=true` and `FAIL_ON_ERROR=false` to let the PCT CLI (instead of the `run-pct` script) checkout the proper
you can use the env variables `DO_NOT_OVERRIDE_PCT_CHECKOUT=true` to let the PCT CLI (instead of the `run-pct` script) checkout the proper
versions of the plugins and make sure the PCT does not stop before testing all plugins.

By using those env variables you can pass a comma separated list of plugins ids using the `ARTIFACT_ID` env variable

```shell
docker run -ti --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -v my/jenkins.war:/pct/jenkins.war:ro -e ARTIFACT_ID=ssh-slaves,credentials -e DO_NOT_OVERRIDE_PCT_CHECKOUT=true -e FAIL_ON_ERROR=false jenkins/pct
docker run -ti --rm -v maven-repo:/root/.m2 -v $(pwd)/out:/pct/out -v my/jenkins.war:/pct/jenkins.war:ro -e ARTIFACT_ID=ssh-slaves,credentials -e DO_NOT_OVERRIDE_PCT_CHECKOUT=true -e jenkins/pct
```

#### Configuration
Expand Down Expand Up @@ -97,28 +97,16 @@ PCT offers the CLI interface which can be used to run PCT locally.

```shell
java -jar target/plugins-compat-tester-cli.jar \
-workDirectory $(pwd)/tmp/work \
-includePlugins ${PLUGIN_ARTIFACT_ID} \
-war jenkins.war -localCheckoutDir ${PLUGIN_SRC} \
-mvn ${PATH_TO_MAVEN}
--working-dir $(pwd)/tmp/work \
--include-plugins ${PLUGIN_ARTIFACT_ID} \
--war jenkins.war --local-checkout-dir ${PLUGIN_SRC} \
--mvn ${PATH_TO_MAVEN}
```

You can run the CLI with the `-help` argument to get a full list of supported options.

:exclamation: For the moment testing more than one plugin at once requires plugins to be released, so for testing SNAPSHOTS you need to execute the last step for every plugin you want to test*

### Running PCT with a BOM file

Plugin Compat Tester supports running test suites using a BOM file as source of truth as follows:

```shell
java -jar target/plugins-compat-tester-cli.jar \
-workDirectory $(pwd)/tmp/work \
-includePlugins ${PLUGIN_ARTIFACT_ID} \
-bom ${BOM_FILE_LOCATION} \
-mvn ${PATH_TO_MAVEN}
```

### Running PCT with custom Java versions

You can run the example by running the following command:
Expand Down
28 changes: 23 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/plugin-compat-tester</gitHubRepo>
<picocli.version>4.7.1</picocli.version>
<slf4j.version>2.0.6</slf4j.version>
<spotbugs.effort>Max</spotbugs.effort>
</properties>
Expand All @@ -41,11 +42,6 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.82</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
Expand All @@ -67,6 +63,11 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>
<dependency>
<groupId>io.jenkins.lib</groupId>
<artifactId>support-log-formatter</artifactId>
Expand Down Expand Up @@ -178,6 +179,23 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- Version specified in parent POM -->
<configuration>
<annotationProcessorPaths>
<path>
<groupId>info.picocli</groupId>
<artifactId>picocli-codegen</artifactId>
<version>${picocli.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
9 changes: 4 additions & 5 deletions src/main/docker/run-pct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ if [ "${SHOULD_CHECKOUT}" -eq 1 ] && [ -z "${DO_NOT_OVERRIDE_PCT_CHECKOUT}" ] ;
mvn -B clean -s "${MVN_SETTINGS_FILE}"
fi
mv "${TMP_CHECKOUT_DIR}" "${PCT_TMP}/localCheckoutDir/${ARTIFACT_ID}"
LOCAL_CHECKOUT_ARG="-localCheckoutDir ${PCT_TMP}/localCheckoutDir/${ARTIFACT_ID}"
LOCAL_CHECKOUT_ARG="--local-checkout-dir ${PCT_TMP}/localCheckoutDir/${ARTIFACT_ID}"
fi


Expand All @@ -157,11 +157,10 @@ fi
pctExitCode=0
echo java ${JAVA_OPTS} ${extra_java_opts[@]} \
-jar /pct/pct-cli.jar \
-workDirectory "${PCT_TMP}/work" ${WAR_PATH_OPT} \
${FAIL_ON_ERROR_ARG}\
--working-dir "${PCT_TMP}/work" ${WAR_PATH_OPT} \
${LOCAL_CHECKOUT_ARG} \
-includePlugins "${ARTIFACT_ID}" \
-m2SettingsFile "${MVN_SETTINGS_FILE}" \
--include-plugins "${ARTIFACT_ID}" \
--maven-settings "${MVN_SETTINGS_FILE}" \
"$@" \
"|| echo \$? > /pct/tmp/pct_exit_code" > /pct/tmp/pct_command
chmod +x /pct/tmp/pct_command
Expand Down
242 changes: 0 additions & 242 deletions src/main/java/org/jenkins/tools/test/CliOptions.java

This file was deleted.

Loading

0 comments on commit b0641fa

Please sign in to comment.