Add support for private jenkins
MODIFY
src/PharoLauncher-Core/PhLJenkins2Entity.class.st
src/PharoLauncher-Core/PhLJenkins2Entity.class.st
@@ -144,7 +144,23 @@ PhLJenkins2Entity >> shouldComputeChildrenLazily [
^ true
]
+{ #category : #accessing }
+PhLJenkins2Entity >> token [
+ ^ parent token
+]
+
{ #category : #accessing }
PhLJenkins2Entity >> url [
- ^ (properties at: 'url') asUrl
+ "We get the URL from the json sent by Jenkins. In case of a secure Jenkins, we need to set the username and token to the URL we get."
+
+ | url |
+ url := (properties at: 'url') asUrl.
+ self username ifNotNil: [ :username | url username: username ].
+ self token ifNotNil: [ :token | url password: token ].
+ ^ url
+]
+
+{ #category : #accessing }
+PhLJenkins2Entity >> username [
+ ^ parent username
]

MODIFY
src/PharoLauncher-Core/PhLJenkins2Job.class.st
src/PharoLauncher-Core/PhLJenkins2Job.class.st
@@ -4,7 +4,7 @@ I'm a job as can be available on a Jenkins platform.
Class {
#name : #PhLJenkins2Job,
#superclass : #PhLJenkins2Entity,
- #category : 'PharoLauncher-Core-Model'
+ #category : #'PharoLauncher-Core-Model'
}
{ #category : #protected }
@@ -26,12 +26,14 @@ PhLJenkins2Job >> builds [
{ #category : #accessing }
PhLJenkins2Job >> lastSuccessfulBuild [
- ^ PhLJenkins2Build
+ ^ (PhLJenkins2Build
newWithProperties:
(Dictionary new
at: 'number' put: self lastSuccessfulBuildNumber;
at: 'url' put: (self url / 'lastSuccessfulBuild') printString;
- yourself)
+ yourself))
+ parent: self;
+ yourself
]
{ #category : #accessing }

MODIFY
src/PharoLauncher-Core/PhLJenkins2Server.class.st
src/PharoLauncher-Core/PhLJenkins2Server.class.st
@@ -9,7 +9,7 @@ Class {
'url',
'name'
],
- #category : 'PharoLauncher-Core-Model'
+ #category : #'PharoLauncher-Core-Model'
}
{ #category : #'instance creation' }
@@ -19,6 +19,14 @@ PhLJenkins2Server class >> name: aString url: anUrl [
yourself
]
+{ #category : #'instance creation' }
+PhLJenkins2Server class >> name: aString url: anUrl username: anotherString token: yetAnotherString [
+ ^ (self name: aString url: anUrl)
+ username: anotherString;
+ token: yetAnotherString;
+ yourself
+]
+
{ #category : #accessing }
PhLJenkins2Server >> jobs [
^ self query: PhLJenkins2Job
@@ -40,7 +48,27 @@ PhLJenkins2Server >> templatesAndGroups [
^ self jobs
]
+{ #category : #accessing }
+PhLJenkins2Server >> token [
+ ^ url password
+]
+
+{ #category : #accessing }
+PhLJenkins2Server >> token: aString [
+ url password: aString
+]
+
{ #category : #accessing }
PhLJenkins2Server >> url [
^ url
]
+
+{ #category : #accessing }
+PhLJenkins2Server >> username [
+ ^ url username
+]
+
+{ #category : #accessing }
+PhLJenkins2Server >> username: aString [
+ url username: aString
+]

MODIFY
src/PharoLauncher-Core/PhLTemplateSource.class.st
src/PharoLauncher-Core/PhLTemplateSource.class.st
@@ -13,7 +13,9 @@ Class {
'url',
'filterPattern',
'templates',
- 'expanded'
+ 'expanded',
+ 'username',
+ 'token'
],
#category : #'PharoLauncher-Core-Model'
}
@@ -274,7 +276,7 @@ PhLTemplateSource >> asBasicTemplateGroup [
url: url asZnUrl
filterPattern: pattern ].
type == self class jenkinsServerType
- ifTrue: [ ^ PhLJenkins2Server name: name url: url asZnUrl ].
+ ifTrue: [ ^ PhLJenkins2Server name: name url: url asZnUrl username: username token: token ].
type == self class urlGroupType
ifTrue: [ ^ PhLFixedURLsTemplateGroup new
setName: name Templates: OrderedCollection new;
@@ -357,6 +359,16 @@ PhLTemplateSource >> templatesDo: aBlockClosure [
templates ifNotNil: [ templates do: aBlockClosure ]
]
+{ #category : #accessing }
+PhLTemplateSource >> token [
+ ^ token
+]
+
+{ #category : #accessing }
+PhLTemplateSource >> token: anObject [
+ token := anObject
+]
+
{ #category : #accessing }
PhLTemplateSource >> type [
^ type
@@ -376,3 +388,13 @@ PhLTemplateSource >> url [
PhLTemplateSource >> url: aString [
url := aString
]
+
+{ #category : #accessing }
+PhLTemplateSource >> username [
+ ^ username
+]
+
+{ #category : #accessing }
+PhLTemplateSource >> username: anObject [
+ username := anObject
+]

MODIFY
src/PharoLauncher-Tests-Download/PhLJenkins2BuildTest.class.st
src/PharoLauncher-Tests-Download/PhLJenkins2BuildTest.class.st
Class {
#name : #PhLJenkins2BuildTest,
#superclass : #PhLJenkins2EntityTest,
- #category : 'PharoLauncher-Tests-Download'
+ #category : #'PharoLauncher-Tests-Download'
}
+{ #category : #'instance creation' }
+PhLJenkins2BuildTest class >> newInstance [
+ | job |
+ job := PhLJenkins2Build
+ newWithProperties: (STONJSON fromString: '{"_class":"hudson.matrix.MatrixBuild","url":"https://ci.inria.fr/moose/job/ClassNamesAnalyzer/223/","number":223}').
+ job parent: PhLJenkins2JobTest newInstance.
+ ^ job
+]
+
+{ #category : #'instance creation' }
+PhLJenkins2BuildTest class >> newSecureJenkinsInstance [
+ | job |
+ job := PhLJenkins2Build
+ newWithProperties: (STONJSON fromString: '{"_class":"hudson.matrix.MatrixBuild","url":"https://ci.inria.fr/moose/job/ClassNamesAnalyzer/223/","number":223}').
+ job parent: PhLJenkins2JobTest newSecureJenkinsInstance.
+ ^ job
+]
+
{ #category : #helpers }
PhLJenkins2BuildTest >> artifactRelativePath [
^ 'foo.zip'
@@ -21,22 +39,22 @@ PhLJenkins2BuildTest >> buildUrlString [
{ #category : #'instance creation' }
PhLJenkins2BuildTest >> emptyBuild [
- ^ PhLJenkins2Build
- newWithProperties:
- (Dictionary new
+ ^ (PhLJenkins2Build newWithProperties: (Dictionary new
at: 'number' put: self buildNumber;
at: 'url' put: self buildUrlString;
- yourself)
+ yourself))
+ parent: PhLJenkins2JobTest newSecureJenkinsInstance;
+ yourself
]
{ #category : #'instance creation' }
PhLJenkins2BuildTest >> emptyLastSuccessfulBuild [
- ^ PhLJenkins2Build
- newWithProperties:
- (Dictionary new
+ ^ (PhLJenkins2Build newWithProperties: (Dictionary new
at: 'number' put: self buildNumber;
at: 'url' put: self lastSuccessfulBuildUrlString;
- yourself)
+ yourself))
+ parent: PhLJenkins2JobTest newSecureJenkinsInstance;
+ yourself
]
{ #category : #helpers }

MODIFY
src/PharoLauncher-Tests-Download/PhLJenkins2EntityTest.class.st
src/PharoLauncher-Tests-Download/PhLJenkins2EntityTest.class.st
Class {
#name : #PhLJenkins2EntityTest,
#superclass : #TestCase,
- #category : 'PharoLauncher-Tests-Download'
+ #category : #'PharoLauncher-Tests-Download'
}
+{ #category : #testing }
+PhLJenkins2EntityTest class >> isAbstract [
+ ^ self = PhLJenkins2EntityTest
+]
+
+{ #category : #'instance creation' }
+PhLJenkins2EntityTest class >> newInstance [
+ ^ self subclassResponsibility
+]
+
+{ #category : #'instance creation' }
+PhLJenkins2EntityTest class >> newSecureJenkinsInstance [
+ ^ self subclassResponsibility
+]
+
+{ #category : #testing }
+PhLJenkins2EntityTest class >> shouldInheritSelectors [
+ ^ true
+]
+
{ #category : #helpers }
PhLJenkins2EntityTest >> downloadManager [
| manager |
@@ -13,6 +33,16 @@ PhLJenkins2EntityTest >> downloadManager [
^ manager
]
+{ #category : #'instance creation' }
+PhLJenkins2EntityTest >> newInstance [
+ ^ self class newInstance
+]
+
+{ #category : #'instance creation' }
+PhLJenkins2EntityTest >> newSecureJenkinsInstance [
+ ^ self class newSecureJenkinsInstance
+]
+
{ #category : #running }
PhLJenkins2EntityTest >> setUp [
super setUp.
@@ -30,3 +60,15 @@ PhLJenkins2EntityTest >> tearDown [
super tearDown.
PhLDownloadManagerMock remove.
]
+
+{ #category : #tests }
+PhLJenkins2EntityTest >> testNonSecureJenkinsDoesNotIncludesIdentifiersInUrl [
+ self deny: self newInstance url hasUsername.
+ self deny: self newInstance url hasPassword
+]
+
+{ #category : #tests }
+PhLJenkins2EntityTest >> testSecureJenkinsIncludesIdentifiersInUrl [
+ self assert: self newSecureJenkinsInstance url hasUsername.
+ self assert: self newSecureJenkinsInstance url hasPassword
+]

MODIFY
src/PharoLauncher-Tests-Download/PhLJenkins2JobTest.class.st
src/PharoLauncher-Tests-Download/PhLJenkins2JobTest.class.st
Class {
#name : #PhLJenkins2JobTest,
#superclass : #PhLJenkins2EntityTest,
- #category : 'PharoLauncher-Tests-Download'
+ #category : #'PharoLauncher-Tests-Download'
}
+{ #category : #helpers }
+PhLJenkins2JobTest class >> newInstance [
+ | job |
+ job := PhLJenkins2Job
+ newWithProperties: (STONJSON fromString: '{"_class":"hudson.matrix.MatrixBuild","url":"https://ci.inria.fr/pharo-contribution/job/A4BP/1304/","number":1304}').
+ job parent: PhLJenkins2ServerTest newInstance.
+ ^ job
+]
+
+{ #category : #helpers }
+PhLJenkins2JobTest class >> newSecureJenkinsInstance [
+ | job |
+ job := PhLJenkins2Job
+ newWithProperties: (STONJSON fromString: '{"_class":"hudson.matrix.MatrixBuild","url":"https://ci.inria.fr/pharo-contribution/job/A4BP/1304/","number":1304}').
+ job parent: PhLJenkins2ServerTest newSecureJenkinsInstance.
+ ^ job
+]
+
{ #category : #helpers }
PhLJenkins2JobTest >> lastSuccessfulBuildNumber [
^ 52
@@ -16,41 +34,38 @@ PhLJenkins2JobTest >> lastSuccessfulBuildUrlString [
{ #category : #'instance creation' }
PhLJenkins2JobTest >> newJobWithNoSuccessfulBuild [
- ^ PhLJenkins2Job
- newWithProperties:
- (Dictionary new
+ ^ (PhLJenkins2Job newWithProperties: (Dictionary new
at: 'url' put: 'url' asUrl;
at: 'name' put: 'thejob';
- yourself)
+ yourself))
+ parent: PhLJenkins2ServerTest newInstance;
+ yourself
]
{ #category : #'instance creation' }
PhLJenkins2JobTest >> newJobWithNullSuccessfulBuild [
- ^ PhLJenkins2Job
- newWithProperties:
- (Dictionary new
+ ^ (PhLJenkins2Job newWithProperties: (Dictionary new
at: 'url' put: 'url' asUrl;
at: 'name' put: 'thejob';
at: 'lastSuccessfulBuild' put: nil;
- yourself)
+ yourself))
+ parent: PhLJenkins2ServerTest newInstance;
+ yourself
]
{ #category : #'instance creation' }
PhLJenkins2JobTest >> newJobWithSuccessfulBuild [
- ^ PhLJenkins2Job
- newWithProperties:
- (Dictionary new
+ ^ (PhLJenkins2Job newWithProperties: (Dictionary new
at: 'url' put: 'url' asUrl;
at: 'name' put: 'thejob';
- at: 'lastSuccessfulBuild'
- put:
- (Dictionary
- newFromPairs:
- {'number'.
- (self lastSuccessfulBuildNumber).
+ at: 'lastSuccessfulBuild' put: (Dictionary newFromPairs: {
+ 'number'.
+ self lastSuccessfulBuildNumber.
'url'.
- (self lastSuccessfulBuildUrlString)});
- yourself)
+ self lastSuccessfulBuildUrlString });
+ yourself))
+ parent: PhLJenkins2ServerTest newInstance;
+ yourself
]
{ #category : #responses }

ADD
src/PharoLauncher-Tests-Download/PhLJenkins2RunTest.class.st
+Class {
+ #name : #PhLJenkins2RunTest,
+ #superclass : #PhLJenkins2EntityTest,
+ #category : #'PharoLauncher-Tests-Download'
+}
+
+{ #category : #'instance creation' }
+PhLJenkins2RunTest class >> newInstance [
+ | job |
+ job := PhLJenkins2Run
+ newWithProperties: (STONJSON fromString: '{"url":"https://ci.inria.fr/pharo-contribution/job/MaterialDesignLite/PHARO=61,VERSION=development/1140/","number":1140}').
+ job parent: PhLJenkins2BuildTest newInstance.
+ ^ job
+]
+
+{ #category : #'instance creation' }
+PhLJenkins2RunTest class >> newSecureJenkinsInstance [
+ | job |
+ job := PhLJenkins2Run
+ newWithProperties: (STONJSON fromString: '{"url":"https://ci.inria.fr/pharo-contribution/job/MaterialDesignLite/PHARO=61,VERSION=development/1140/","number":1140}').
+ job parent: PhLJenkins2BuildTest newSecureJenkinsInstance.
+ ^ job
+]

MODIFY
src/PharoLauncher-Tests-Download/PhLJenkins2ServerTest.class.st
src/PharoLauncher-Tests-Download/PhLJenkins2ServerTest.class.st
Class {
#name : #PhLJenkins2ServerTest,
#superclass : #PhLJenkins2EntityTest,
- #category : 'PharoLauncher-Tests-Download'
+ #category : #'PharoLauncher-Tests-Download'
}
+{ #category : #'instance creation' }
+PhLJenkins2ServerTest class >> newInstance [
+ ^ PhLJenkins2Server name: 'foo' url: 'bar' asUrl
+]
+
+{ #category : #'instance creation' }
+PhLJenkins2ServerTest class >> newSecureJenkinsInstance [
+ ^ self newInstance
+ username: 'Christophe';
+ token: 'dkewjdcnriuwefjncreiuhf';
+ yourself
+]
+
{ #category : #responses }
PhLJenkins2ServerTest >> defaultJobName [
^ 'theJobName'
@@ -22,7 +35,12 @@ PhLJenkins2ServerTest >> jobsResponse [
{ #category : #'instance creation' }
PhLJenkins2ServerTest >> newInstance [
- ^ PhLJenkins2Server name: 'foo' url: 'bar' asUrl
+ ^ self class newInstance
+]
+
+{ #category : #'instance creation' }
+PhLJenkins2ServerTest >> newSecureJenkinsInstance [
+ ^ self class newSecureJenkinsInstance
]
{ #category : #responses }

Add support for private jenkins