项目作者: leventarican

项目描述 :
Continuous Integtration
高级语言: Java
项目地址: git://github.com/leventarican/Jenkins.git
创建时间: 2018-09-20T03:24:53Z
项目社区:https://github.com/leventarican/Jenkins

开源协议:

下载


jenkins.

run jenkins

  • get .war from https://jenkins.io/
  • run: java -jar jenkins.war
  • jenkins is reachable under: localhost:8080
  • initial password can be found here: ~/.jenkins/secrets/initialAdminPassword
  • jenkins default location: ~/.jenkins
  • default user:password: admin:admin

example pipeline

  • this pipeline uses credentials and write it to a file: credentials.txt
  • create a credentials under: http://localhost:8080/credentials/store/system/domain/_/newCredentials
    • in the example I used: jenkins_credential_0
  • create a new job: http://localhost:8080/view/all/newJob
  • paste pipeline code

    • based on: https://jenkins.io/doc/pipeline/examples/

      1. // This shows a simple example of how to archive the build output artifacts.
      2. node {
      3. stage "Create build output"
      4. // Make the output directory.
      5. sh "mkdir -p output"
      6. // Write an useful file, which is needed to be archived.
      7. writeFile file: "output/usefulfile.txt", text: "This file is useful, need to archive it."
      8. // Write an useless file, which is not needed to be archived.
      9. writeFile file: "output/uselessfile.md", text: "This file is useless, no need to archive it."
      10. writeFile file: "output/usefulfile.txt", text: "This file is useful, need to archive it."
      11. stage "credentials"
      12. withCredentials([usernamePassword(credentialsId: 'jenkins_credential_0', passwordVariable: 'bar', usernameVariable: 'foo')]) {
      13. writeFile file: "output/credentials.txt", text: bar
      14. }
      15. stage "Archive build output"
      16. // Archive the build output artifacts.
      17. archiveArtifacts artifacts: 'output/*.txt', excludes: 'output/*.md'
      18. stage "pwd"
      19. sh "ls -la ${pwd()}"
      20. echo "done."
      21. }

jenkins with github

jenkins

  • configure github under jenkins system configuration
  • create a github token
  • at jenkins job select the github repository

github