Skip to content

Commit c1c52b3

Browse files
committed
License Update, Package rename
1 parent 4d52183 commit c1c52b3

16 files changed

+234
-45
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: go
2+
3+
go:
4+
- 1.2
5+
- 1.3
6+
- tip
7+
install:
8+
- go get github.com/stretchr/testify/assert

AUTHOR

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Vadim Kravcenko 2014

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
1-
go-jenkins
2-
==========
1+
# Jenkins API Client for Go
2+
3+
## About
4+
5+
Jenkins is the most popular Open Source Continuous Integration system. This Library will help you interact with Jenkins in a more developer-friendly way.
6+
7+
These are some of the features that are currently implemented:
8+
9+
* Get information on test-results of completed/failed build
10+
* Ability to query Nodes, and manipulate them. Start, Stop, set Offline.
11+
* Ability to query Jobs, and manipulate them.
12+
* Validate Fingerprints of Artifacts
13+
* Get Current Queue, Cancel Tasks
14+
* etc.
15+
16+
## Installation
17+
18+
go get github.com/bndr/gojenkins
19+
20+
## Usage
21+
22+
23+
## Examples
24+
25+
## Testing
26+
27+
## Contribute
28+
29+
All Contributions are welcome. The todo list is on the bottom of this README. Feel free to send a pull request.
30+
31+
## TODO
32+
33+
Although the basic features are implemented there are many optional features that are on the todo list.
34+
35+
* Kerberos Authentication
36+
* CLI Tool
37+
* Rewrite some (all?) iterators with channels
38+
39+
## LICENSE
40+
41+
Apache License 2.0

artifact.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
package main
1+
// Copyright 2014 Vadim Kravcenko
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"): you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
package gojenkins
216

317
import (
418
"crypto/md5"

build.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
package main
1+
// Copyright 2014 Vadim Kravcenko
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"): you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
package gojenkins
216

317
import (
418
"strconv"

constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gojenkins
22

33
const (
44
STATUS_FAIL = "FAIL"

executor.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
package main
1+
// Copyright 2014 Vadim Kravcenko
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"): you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
package gojenkins
216

317
type executor struct {
418
Raw *executorResponse

fingerprint.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
package main
1+
// Copyright 2014 Vadim Kravcenko
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"): you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
package gojenkins
216

317
type Fingerprint struct {
418
Jenkins *Jenkins

jenkins.go

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
package main
1+
// Copyright 2014 Vadim Kravcenko
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"): you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
// Gojenkins is a Jenkins Client in Go, that exposes the jenkins REST api in a more developer friendly way.
16+
package gojenkins
217

318
import (
419
"crypto/tls"
5-
"fmt"
620
"log"
721
"net/http"
822
"net/http/cookiejar"
@@ -11,16 +25,12 @@ import (
1125
"strings"
1226
)
1327

28+
// Basic Authentication
1429
type BasicAuth struct {
1530
Username string
1631
Password string
1732
}
1833

19-
type TokenAuth struct {
20-
Username string
21-
Token string
22-
}
23-
2434
type Jenkins struct {
2535
Server string
2636
Version string
@@ -29,29 +39,29 @@ type Jenkins struct {
2939
}
3040

3141
// Loggers
32-
3342
var (
3443
Info *log.Logger
3544
Warning *log.Logger
3645
Error *log.Logger
3746
)
3847

39-
// Jenkins
40-
48+
// Init Method. Should be called after creating a Jenkins Instance.
49+
// e.g jenkins := CreateJenkins("url").Init()
50+
// HTTP Client is set here, Connection to jenkins is tested here.
4151
func (j *Jenkins) Init() *Jenkins {
4252
j.initLoggers()
4353
// Skip SSL Verification?
4454
tr := &http.Transport{
4555
TLSClientConfig: &tls.Config{InsecureSkipVerify: !j.Requester.SslVerify},
4656
}
4757

48-
cookies, _ := cookiejar.New(nil)
49-
50-
client := &http.Client{
51-
Transport: tr,
52-
Jar: cookies,
53-
}
5458
if j.Requester.Client == nil {
59+
cookies, _ := cookiejar.New(nil)
60+
61+
client := &http.Client{
62+
Transport: tr,
63+
Jar: cookies,
64+
}
5565
j.Requester.Client = client
5666
}
5767

@@ -79,6 +89,7 @@ func (j *Jenkins) initLoggers() {
7989
log.Ldate|log.Ltime|log.Lshortfile)
8090
}
8191

92+
// Get Basic Information About Jenkins
8293
func (j *Jenkins) Info() *executorResponse {
8394
j.Requester.Do("GET", "/", nil, j.Raw, nil)
8495
return j.Raw
@@ -222,7 +233,7 @@ func (j *Jenkins) GetAllJobs(preload bool) []*Job {
222233
}
223234

224235
func (j *Jenkins) GetQueue() *Queue {
225-
q := &Queue{Jenkins: j, Raw: new(queueResponse), Base: "/queue"}
236+
q := &Queue{Jenkins: j, Raw: new(queueResponse), Base: j.GetQueueUrl()}
226237
q.Poll()
227238
return q
228239
}
@@ -256,6 +267,9 @@ func (j *Jenkins) ValidateFingerPrint(id string) bool {
256267
return false
257268
}
258269

270+
// Creates a new Jenkins Instance
271+
// Optional parameters are: username, password
272+
// After creating an instance call init method.
259273
func CreateJenkins(base string, auth ...interface{}) *Jenkins {
260274
j := &Jenkins{}
261275
if strings.HasSuffix(base, "/") {
@@ -268,15 +282,3 @@ func CreateJenkins(base string, auth ...interface{}) *Jenkins {
268282
}
269283
return j
270284
}
271-
272-
func main() {
273-
j := CreateJenkins("http://localhost:8080/", "admin", "admin").Init()
274-
275-
//fmt.Printf("%#v\n", j.GetJob("testJobName").Raw.Description)
276-
job := j.GetJob("testjib")
277-
ts := job.GetLastBuild()
278-
ts.GetArtifacts()[0].Save("/tmp/tabulateFile")
279-
fmt.Printf("%#v", j.GetPlugins(1).Contains("ldap"))
280-
//fmt.Printf("%#v\n", job.GetLastBuild().Info())
281-
// fmt.Printf("%#v", j.CreateNode("wat23s1131sssasd1121", 2, "description", "/f/vs/sa/"))
282-
}

job.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
package main
1+
// Copyright 2014 Vadim Kravcenko
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"): you may
4+
// not use this file except in compliance with the License. You may obtain
5+
// a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
// License for the specific language governing permissions and limitations
13+
// under the License.
14+
15+
package gojenkins
216

317
import (
418
"bytes"

0 commit comments

Comments
 (0)