Improved Jenkinsfile structure
All checks were successful
JCS-Prod/RSE-Texture/pipeline/head This commit looks good

This commit is contained in:
JackCarterSmith 2021-07-03 15:21:31 +02:00
parent 84e0a0b904
commit 9f98830fce
Signed by: JackCarterSmith
GPG Key ID: DB362B740828F843
2 changed files with 100 additions and 65 deletions

View File

@ -1,49 +1,63 @@
# CMakeLists.txt
# Written by JackCarterSmith, 2020
# This code is released under the RSE license.
cmake_minimum_required(VERSION 3.1)
cmake_policy(VERSION 3.1)
# define project
project(rse-texture VERSION 1.0.1 DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C)
set(RSE_TEX_NAME RSE_Texture-${PROJECT_VERSION})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
# needed packages
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
# define src/headers files
FILE(GLOB RSE_TEX_SRCS src/*.c)
FILE(GLOB RSE_TEX_HRDS src/*.h)
SOURCE_GROUP("Source Files" FILES ${RSE_TEX_SRCS})
SOURCE_GROUP("Header Files" FILES ${RSE_TEX_HRDS})
# begin building RSE-Texture
#set(CMAKE_BUILD_TYPE Debug)
#include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(rse-texture ${RSE_TEX_SRCS} ${RSE_TEX_HRDS})
#set_property(TARGET rse-texture PROPERTY C_STANDARD 99)
set_target_properties(rse-texture PROPERTIES OUTPUT_NAME ${RSE_TEX_NAME})
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(rse-texture PROPERTIES PREFIX "lib")
set_target_properties(rse-texture PROPERTIES IMPORT_PREFIX "lib")
endif()
target_link_libraries(rse-texture ${ZLIB_LIBRARIES} ${PNG_LIBRARIES})
# install executable
install(TARGETS rse-texture
RUNTIME DESTINATION bin
# CMakeLists.txt
# Written by JackCarterSmith, 2020
# This code is released under the RSE license.
cmake_minimum_required(VERSION 3.1)
cmake_policy(VERSION 3.1)
# define project
if(DEFINED ENV{CI})
project(rse-texture VERSION 1.0.1.$ENV{CI_BUILD_NUMBER} DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C)
set(RSE_TEX_NAME $ENV{CI_OUTPUT_NAME}-${PROJECT_VERSION})
else()
project(rse-texture VERSION 1.0.1 DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C)
set(RSE_TEX_NAME RSE_Texture-${PROJECT_VERSION})
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
# needed packages
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
# define src/headers files
FILE(GLOB RSE_TEX_SRCS src/*.c)
FILE(GLOB RSE_TEX_HRDS src/*.h)
SOURCE_GROUP("Source Files" FILES ${RSE_TEX_SRCS})
SOURCE_GROUP("Header Files" FILES ${RSE_TEX_HRDS})
# begin building RSE-Texture
#set(CMAKE_BUILD_TYPE Debug)
#include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(rse-texture ${RSE_TEX_SRCS} ${RSE_TEX_HRDS})
#set_property(TARGET rse-texture PROPERTY C_STANDARD 99)
set_target_properties(rse-texture PROPERTIES OUTPUT_NAME ${RSE_TEX_NAME})
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(rse-texture PROPERTIES PREFIX "lib")
set_target_properties(rse-texture PROPERTIES IMPORT_PREFIX "lib")
endif()
target_link_libraries(rse-texture ${ZLIB_LIBRARIES} ${PNG_LIBRARIES})
# add GPG signature command
#add_custom_command(
# OUTPUT ""
# COMMAND gpg --batch --detach-sign
# -o ${RSE_TEX_NAME}_${CI_SYS_TARGET}.gpg
# ${RSE_TEX_NAME}
# DEPENDS ${RSE_TEX_NAME}
# VERBATIM
#)
# install executable
install(TARGETS rse-texture
RUNTIME DESTINATION bin
)

55
Jenkinsfile vendored
View File

@ -3,38 +3,58 @@ pipeline {
options {
skipDefaultCheckout(true)
}
environment {
CI_OUTPUT_NAME = "RSE_Texture"
CI_BUILD_NUMBER = "$BUILD_NUMBER"
}
stages {
stage('Unix-Build') {
stage('Prepare') {
steps {
cleanWs()
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
echo 'Build Unix x64_86 release...'
cmakeBuild buildDir: 'build', installation: 'latest', steps: [[args: 'all']]
}
}
stage('Unix-Deploy') {
stage('Build') {
steps {
echo 'Deploying solution...'
sh 'gpg --batch --detach-sign -o build/${JOB_BASE_NAME}_x64_1.0.1-${BUILD_NUMBER}.gpg build/RSE_Texture-1.0.1'
archiveArtifacts(artifacts: 'build/RSE_Texture-*,build/*.gpg')
parallel(
linux: {
dir("linux") {
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
cmakeBuild buildDir: 'build', installation: 'latest', steps: [[args: 'all']]
}
},
windows: {
dir("windows") {
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
cmakeBuild buildDir: 'build', cmakeArgs: '-DGNU_HOST=x86_64-w64-mingw32 -DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake -D"ZLIB_INCLUDE_DIR=/mnt/cc-libs/mingw64/zlib/1.2.11/include" -D"ZLIB_LIBRARY=/mnt/cc-libs/mingw64/zlib/1.2.11/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=/mnt/cc-libs/mingw64/libpng/1.6.37/include" -D"PNG_LIBRARY=/mnt/cc-libs/mingw64/libpng/1.6.37/lib/libpng.dll.a"', installation: 'latest', steps: [[args: 'all']]
}
}
)
}
}
stage('Win-Build') {
stage('Deploy') {
steps {
cleanWs()
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
echo 'Build Windows mingw64 release...'
cmakeBuild buildDir: 'build', cmakeArgs: '-DGNU_HOST=x86_64-w64-mingw32 -DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake -D"ZLIB_INCLUDE_DIR=/mnt/cc-libs/mingw64/zlib/1.2.11/include" -D"ZLIB_LIBRARY=/mnt/cc-libs/mingw64/zlib/1.2.11/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=/mnt/cc-libs/mingw64/libpng/1.6.37/include" -D"PNG_LIBRARY=/mnt/cc-libs/mingw64/libpng/1.6.37/lib/libpng.dll.a"', installation: 'latest', steps: [[args: 'all']]
dir("zip_linux") {
sh 'cp ../linux/build/${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}* .'
}
dir("zip_win") {
sh 'cp ../windows/build/${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}* /mnt/cc-libs/mingw64/zlib/1.2.11/bin/libzlib.dll /mnt/cc-libs/mingw64/libpng/1.6.37/bin/libpng16.dll .'
}
zip archive: false, dir: 'zip_linux', exclude: '', glob: '', zipFile: 'x64.zip'
sh 'mv x64.zip ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_x64.zip'
zip archive: false, dir: 'zip_win', exclude: '', glob: '', zipFile: 'mingw64.zip'
sh 'mv mingw64.zip ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_mingw64.zip'
}
}
stage('Win-Deploy') {
stage('Sign') {
steps {
echo 'Deploying solution...'
sh 'gpg --batch --detach-sign -o build/${JOB_BASE_NAME}_mingw64_1.0.1-${BUILD_NUMBER}.gpg build/RSE_Texture-1.0.1.exe'
archiveArtifacts(artifacts: 'build/RSE_Texture-*.exe,build/*.gpg')
sh 'ls -l'
sh 'gpg --batch --detach-sign -o ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_x64.zip.gpg ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_x64.zip'
sh 'gpg --batch --detach-sign -o ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_mingw64.zip.gpg ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_mingw64.zip'
archiveArtifacts(artifacts: '*.zip,*.gpg')
}
}
}
/*
post {
always {
cleanWs(cleanWhenNotBuilt: false,
@ -43,4 +63,5 @@ pipeline {
notFailBuild: true)
}
}
*/
}