Is there a way to keep Hudson / Jenkins configuration files in source control?

后端 未结 10 808
难免孤独
难免孤独 2020-11-29 15:45

I am new to Hudson / Jenkins and was wondering if there is a way to check in Hudson\'s configuration files to source control.

Ideally I want to be able to click some

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 16:13

    You can find configuration files in Jenkins home folder (e.g. /var/lib/jenkins).

    To keep them in VCS, first login as Jenkins (sudo su - jenkins) and create its git credentials:

    git config --global user.name "Jenkins"
    git config --global user.email "jenkins@example.com"
    

    Then initialize, add and commit the basic files such as:

    git init
    git add config.xml jobs/ .gitconfig
    git commit -m'Adds Jenkins config files' -a
    

    also consider creating .gitignore with the following files to ignore (customize as needed):

    # Git untracked files to ignore.
    
    # Cache.
    .cache/
    
    # Fingerprint records.
    fingerprints/
    
    # Working directories.
    workspace/
    
    # Secret files.
    secrets/
    secret.*
    *.enc
    *.key
    users/
    id_rsa
    
    # Plugins.
    plugins/
    
    # State files.
    *.state
    
    # Job state files.
    builds/
    lastStable
    lastSuccessful
    nextBuildNumber
    
    # Updates.
    updates/
    
    # Hidden files.
    .*
    # Except git config files.
    !.git*
    !.ssh/
    
    # User content.
    userContent/
    
    # Log files.
    logs/
    *.log
    
    # Miscellaneous litter
    *.tmp
    *.old
    *.bak
    *.jar
    *.json
    *.lastExecVersion
    

    Then add it: git add .gitignore.

    When done, you can add job config files, e.g.

    shopt -s globstar
    git add **/config.xml
    git commit -m'Added job config files' -a
    

    Finally add and commit any other files if needed, then push it to the remote repository where you want to keep the config files.


    When Jenkins files are updated, you need to reload them (Reload Configuration from Disk) or run reload-configuration from Jenkins CLI.

提交回复
热议问题