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
Problem Compiling Source Code #12
Comments
This is totally correct - Your build tools - like The example repositories are provided to show what a project that uses You only need to build |
I am able to connect to http://repo.jenkins-ci.org/releases just fine right now from my personal machine... A connection timeout on port 80 suggests one of the following:
Are you able to access http://repo.jenkins-ci.org/releases in
|
Hi Austin,
The issue has been resolved by adding the XML element:
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
What I want to do is to test this on a fresh machine and then submit a pull
request. I hope to get most of this done today, but it will be done latest
by mid next week. I will also send you a ramp up guide useful for people
like me. (In other words, my notes written as a walk through for Windows
developer.)
Thanks for the help the past week. I am close to be able to test my own
shared library code.
BTW, what do you use to generate code coverage percentages?
…--Ming
On Wed, Oct 10, 2018 at 4:43 PM Austin ***@***.***> wrote:
I am beginning to suspect that I don't need to do the build myself to use
Jenkins-Spock. If so, can you provide me with some pointers?
This is totally correct - jenkins-spock is available for download in a
JAR from the Maven Central repository:
https://search.maven.org/search?q=a:jenkins-spock
Your build tools - like maven and gradle - will be able to retrieve the
necessary code from there even if you never build jenkins-spock locally.
The example repositories are provided to show what a project that uses
jenkins-spock *might look like*.
You only need to build jenkins-spock yourself if you want to make changes
to how it works - you don't need to build it to use it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoFJGZ8fn3brB5GupYgHwT-nGRR_2__Fks5ujoY0gaJpZM4XNybl>
.
|
I haven't figured that out for Jenkins Pipeline code. Most of the pipeline scripts are loaded as groovy scripts - not as compiled JVM code - so traditional code-coverage tools won't work. I haven't explored code coverage tools for Groovy scripts. |
(Looking forward to your pull request!) |
I have attached my ramping guide. It is pretty big because of ample use of
screenshots. Feel free to pass/post it. Hopefully, it will help others.
OK, I double checked my work on a clean system. This is what I found.
* There is no need for a pull request. <pluginRepositories> is not
necessary.
* The strange behavior I saw was a combination of:
* Jenkins (Cloudbees) having 2 repos. *https*://
repo.jenkins-ci.org/public and *http*://repo.jenkins-ci.org/releases
* These two repos have many artifacts, but *not *all in common;
this added to the confusion!
* My Maven was only configured for *https*.
The upshot is that the strange time-out behavior can occur in
*seemingly *random
fashion if proxies for both http and https are not configured correctly for
Maven.
Two more questions.
*1. Can Jenkins-Spock handle Declarative Pipelines?* I tried and could not
get it to work.
*2. If Jenkins-Spock cannot handle Declarative Pipelines, what do you
suggest I do?*
Thanks for all your help.
--Ming
…On Mon, Oct 15, 2018 at 8:25 AM Austin ***@***.***> wrote:
(Looking forward to your pull request!)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoFJGUM7EB32f8qnJRweWcCuoiCUjvKBks5ulKjrgaJpZM4XNybl>
.
|
@cmcheungMOOC , I think when you reply to an Issue e-mail with an attachment, GitHub discards the attachment - I don't see your guide on GitHub.com, nor in my inbox.
No, not the way you're thinking. It will handle declarative pipelines "properly" if you add the declarative pipeline plugin as a dependency... But all "declarative pipeline" is is a Jenkins Pipeline Step named So, it will be mocked and you can interact with the declarative pipeline specification in your Spock unit tests... but the declarative pipeline specification is data, not executable code. The implementation of the Unit-testing a declarative pipeline specification is similar to asking to unit-test an XML or YAML file - it's data: it doesn't make sense to unit-test it. You might want to check it against a schema, or make assertions about the structure of the data.
Short-term, I don't have any path that will accelerate you: someone will have to investigate and determine if it's possible to use the declarative pipeline engine's code in conjunction with Spock, to allow users to
I do believe that would be a valuable enhancement. |
OK, I will send the doc to your work email instead. Another question.
Does Jenkins-Spock support Spy()? I like to create a
Spy(myTestSubjectClass), and I don't think you can do this with
loadPipelineScriptForTest(). Am I correct?
The reason why I need it is that one of my methods in my test subject class
generates a uniqueID each time it is called. This makes testing it
complicated.
…On Thu, Oct 18, 2018 at 2:37 PM Austin ***@***.***> wrote:
@cmcheungMOOC <https://github.com/cmcheungMOOC> , I think when you reply
to an Issue e-mail with an attachment, GitHub discards the attachment - I
don't see your guide on GitHub.com, nor in my inbox.
Can Jenkins-Spock handle Declarative Pipelines?
No, not the way you're thinking.
It *will* handle declarative pipelines "properly" if you add the
declarative pipeline plugin as a dependency... But all "declarative
pipeline" is is a *Jenkins Pipeline Step* named pipeline that consumes
the *declarative pipeline specification* as data.
So, it will be mocked and you can interact with the declarative pipeline
specification in your Spock unit tests... but the declarative pipeline
specification is *data*, not executable code. The implementation of the
pipeline step does things based on that input data - but that code does
not live in jenkins-spock.
Unit-testing a declarative pipeline specification is similar to asking to
unit-test an XML or YAML file - it's data: it doesn't make sense to
unit-test it.
You might want to check it against a *schema*, or make assertions about
the structure of the data.
jenkins-spock does not currently have any tooling to assist with this.
If Jenkins-Spock cannot handle Declarative Pipelines, what do you
suggest I do?
Short-term, I don't have any path that will accelerate you: someone will
have to investigate and determine if it's possible to use the declarative
pipeline engine's code in conjunction with Spock, to allow users to
1. Validate their pipeline declaration
2. Make assertions about the structure of their pipeline declaration
I do believe that would be a valuable enhancement.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoFJGch1XlbVrD_lkrvhe4YcW4hFJF8aks5umPSRgaJpZM4XNybl>
.
|
I don't believe it does anything that will block But, classes and If you have a real Groovy class, you don't need
public class MyTestSubjectClassSpec extends JenkinsPipelineSpecification {
def "some specification"() {
setup:
MyTestSubjectClass myspy = Spy()
myspy().someMethod(_) >> {
// some stubbed behavior
}
when:
myspy.doSomething()
then:
1 * myspy.someExpectedMethod()
}
} (or similar) |
So basically you are saying that I cannot stub out methods of my test
subject. Am I correct?
An somewhat unrelated question. Is the fact that the test subject is
loaded into a Groovy script object the reason I cannot get code coverage
results?
I have tried OpenClover, cobertura and Jacoco.
OpenClover did not even create a clover.db, cobertura create nothing
visible to me. Jacoco did generate a report but only on the test code in
the *Spec.groovy file itself. There is an entry called
*Spec.__spock_feature_1_1_closure1 that I suspect is the test subject, but
considering that the name gives no meaningful information, it is not too
useful.
…On Tue, Oct 23, 2018 at 8:02 AM Austin ***@***.***> wrote:
Does Jenkins-Spock support Spy()?
I don't believe it does anything that will block Spy().
But, *classes* and loadPipelineScriptForTest probably shouldn't be used
together: loadPipelineScriptForTest loads Groovy *scripts* into a
groovy.lang.Script object
<http://groovy-lang.org/structure.html#_script_class>.
If you have a real Groovy class, you don't need loadPipelineScriptForTest;
you can just test that class normally:
MyTestSubjectClassSpec.groovy:
public class MyTestSubjectClassSpec extends JenkinsPipelineSpecification {
def "some specification"() {
setup:
MyTestSubjectClass myspy = Spy()
myspy().someMethod(_) >> {
// some stubbed behavior
}
when:
myspy.doSomething()
then:
1 * myspy.someExpectedMethod()
}
}
(or similar)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoFJGUBfaS90BJcQEu5S7ZyIbv1N1dlXks5uny-RgaJpZM4XNybl>
.
|
No, you should be able to do that. If your
Yes. Groovy "scripts" start their life as plain text (not source code), and are loaded at runtime. Most code-coverage tools I've seen rely on instrumenting the JVM and/or the bytecode, to connect method calls to source code. There isn't "source code" in the way those tools are expecting, nor is there any bytecode that maps to the source file. I do not know of a solution to this. |
@cmcheungMOOC , do you still need assistance with this issue? |
Expected Behavior
mvn compile should work without error.
Actual Behavior
I ran mvn compile at two different directories.
From jenkins-spock directory:
[ERROR] Failed to execute goal on project jenkins-spock: Could not resolve dependencies for project com.homeaway.devtools.jenkins:jenkins-spock:jar:yes: Failed to collect dependencies at org.jenkins-ci.main:jenkins-core:jar:2.102: Failed to read artifact descriptor for org.jenkins-ci.main:jenkins-core:jar:2.102: Could not transfer artifact org.jenkins-ci.main:jenkins-core:pom:2.102 from/to jenkins-releases (http://repo.jenkins-ci.org/releases): Connect to repo.jenkins-ci.org:80 [repo.jenkins-ci.org/130.211.20.35] failed: Connection timed out: connect -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project jenkins-spock: Could not resolve dependencies for project com.homeaway.devtools.jenkins:jenkins-spock:jar:yes: Failed to collect dependencies at org.jenkins-ci.main:jenkins-core:jar:2.102
From shared-library directory
[ERROR] Failed to execute goal on project jenkinsfile-test-shared-library: Could not resolve dependencies for project com.example:jenkinsfile-test-shared-library:jar:0.0.0-SNAPSHOT: Failed to collect dependencies at org.jenkins-ci.main:jenkins-core:jar:2.102: Failed to read artifact descriptor for org.jenkins-ci.main:jenkins-core:jar:2.102: Could not transfer artifact org.jenkins-ci.main:jenkins-core:pom:2.102 from/to jenkins-releases (http://repo.jenkins-ci.org/releases): Connect to repo.jenkins-ci.org:80 [repo.jenkins-ci.org/130.211.20.35] failed: Connection timed out: connect -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project jenkinsfile-test-shared-library: Could not resolve dependencies for project com.example:jenkinsfile-test-shared-library:jar:0.0.0-SNAPSHOT: Failed to collect dependencies at org.jenkins-ci.main:jenkins-core:jar:2.102
Steps to Reproduce
The mvn compile was performed on a Windows box.
Additional Information
I am beginning to suspect that I don't need to do the build myself to use Jenkins-Spock. If so, can you provide me with some pointers? I am still trying to make sense of the Java ecosystem.
The text was updated successfully, but these errors were encountered: